Statistics API
Mean, median, mode, range, variance and standard deviation (population and sample) of a list of numbers.
POST https://api.curatedapi.com/v1/calc/math/statistics
- Version 1
- MCP tool
calc_math_statistics - Try it in the browser
Computes descriptive statistics exactly. Sums, means and variances are exact fractions; standard deviations are square roots computed with certified arithmetic, so even long lists of decimals give correctly rounded results with no accumulated floating-point error.
Formula
mean = Σx/n; population variance = Σ(x − mean)²/n; sample variance = Σ(x − mean)²/(n − 1); standard deviation = √variance
Inputs
Send numbers as strings to keep every digit. options sets precision and rounding (see numbers and rounding).
| Input | Type | Description |
|---|---|---|
values required |
list of decimal (string) | The data, as a list of numbers. 1 to 10000 items. |
options.rounding |
half_even | half_up | half_down | up | down | ceiling | floor | Rounding mode applied once to each result. Default half_even. |
options.decimals |
integer | Round results to this many digits after the decimal point. |
options.significant_digits |
integer | Round results to this many significant digits. |
Result
Under result in the answer, next to exactness, precision, inputs, formula, references and warnings.
| Result | Type | Description |
|---|---|---|
count | integer | Number of values. |
sum | decimal (string) | Sum of the values. |
mean | decimal (string) | Arithmetic mean. |
median | decimal (string) | Middle value (mean of the two middle values for an even count). |
mode | list of string | Most frequent value(s), exact; empty when no value repeats. |
minimum | decimal (string) | Smallest value. |
maximum | decimal (string) | Largest value. |
range | decimal (string) | Maximum minus minimum. |
population_variance | decimal (string) | Σ(x − mean)² / n. |
population_std_dev | decimal (string) | Square root of the population variance. |
sample_variance | decimal (string) | Σ(x − mean)² / (n − 1) (needs n ≥ 2). |
sample_std_dev | decimal (string) | Square root of the sample variance (needs n ≥ 2). |
Examples
Classic example
curl https://api.curatedapi.com/v1/calc/math/statistics \
-H "Authorization: Bearer $CURATEDAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"values": ["2", "4", "4", "4", "5", "5", "7", "9"]
}'
{
"calculator": "math/statistics@1",
"result": {
"count": 8,
"sum": "40",
"mean": "5",
"median": "4.5",
"mode": [
"4"
],
"minimum": "2",
"maximum": "9",
"range": "7",
"population_variance": "4",
"population_std_dev": "2",
"sample_variance": "4.57142857142857",
"sample_std_dev": "2.1380899352994"
},
"exactness": {
"sum": "exact",
"mean": "exact",
"median": "exact",
"minimum": "exact",
"maximum": "exact",
"range": "exact",
"population_variance": "exact",
"population_std_dev": "exact",
"sample_variance": "rounded",
"sample_std_dev": "rounded"
},
"precision": {
"rounding": "half_even",
"significant_digits": 15
},
"inputs": {
"values": [
"2",
"4",
"4",
"4",
"5",
"5",
"7",
"9"
]
},
"formula": "mean = Σx/n; population variance = Σ(x − mean)²/n; sample variance = Σ(x − mean)²/(n − 1); standard deviation = √variance",
"references": [
{
"title": "NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.5: measures of location and scale",
"url": "https://www.itl.nist.gov/div898/handbook/eda/section3/eda35.htm"
}
],
"warnings": []
}
References
Results follow each calculator's documented rules and the sources listed. They are not financial, tax or legal advice. Check that the rules fit your case before you rely on a result. See the terms.
Errors share one format; see errors. Billing, retries and batches work the same for every endpoint.