Skip to content

Statistics ​

The /statistics endpoint calculates descriptive statistics on a list of numbers.

How it works?

All measures are computed on the full population (not a sample). variance and stddev use population formulas (divide by N). mode returns all values tied for the highest frequency. mean, median, variance, and stddev are rounded to 6 decimal places.

Parameters ​

ParameterRequiredDescription
valuesYesComma-separated list of numbers (max 1000 values)

Response Fields ​

FieldTypeDescription
countnumberNumber of values
sumnumberSum of all values
minnumberMinimum value
maxnumberMaximum value
rangenumberDifference between max and min
meannumberArithmetic mean
mediannumberMedian value
modenumber[]Most frequent value(s)
variancenumberPopulation variance
stddevnumberStandard deviation

mean, median, variance, and stddev are returned with up to 6 decimal places of precision.

Code Examples ​

curl -X GET \
  "https://api.sylvain.sh/v6/statistics?values=1%2C2%2C3%2C4%2C5"

Try It ​

Error Handling ​

If parameters are missing or invalid, the API will return an error:

Error MessageDescription
Please provide a comma-separated list of numbers (?values=…)The values parameter is missing or invalid