curatedapi
Browse the docs

Guides

Finance

Excel functions

Late payments

E-invoices

Accounting

Number checks

VAT and GST

Billing and pricing

Money and currencies

Dates and time

Math

Unit conversion

Everyday

Health

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

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).

InputTypeDescription
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.

ResultTypeDescription
countintegerNumber of values.
sumdecimal (string)Sum of the values.
meandecimal (string)Arithmetic mean.
mediandecimal (string)Middle value (mean of the two middle values for an even count).
modelist of stringMost frequent value(s), exact; empty when no value repeats.
minimumdecimal (string)Smallest value.
maximumdecimal (string)Largest value.
rangedecimal (string)Maximum minus minimum.
population_variancedecimal (string)Σ(x − mean)² / n.
population_std_devdecimal (string)Square root of the population variance.
sample_variancedecimal (string)Σ(x − mean)² / (n − 1) (needs n ≥ 2).
sample_std_devdecimal (string)Square root of the sample variance (needs n ≥ 2).

Examples

Classic example

Requestcurl
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"]
  }'
200 OKResponse
{
  "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.