Statistics Calculator

Calculate mean, median, population and sample standard deviations, and weighted mean. Aggregate decimals exactly, then copy or save a JSON report.

How to use

  1. Enter the numbers and optionally supply corresponding weights for a weighted mean.
  2. Calculate and review the mean, median, variance and other results.
  3. Distinguish population and sample statistics and save the JSON report if needed.

Numbers and weights

Separate numbers with line breaks, spaces or tabs. Use plain digits, decimal points, signs or e notation; commas are not supported. Optional weights must match the numbers in count and order.

Each UTF-8 input: 1 MB and 10,000 values. Each token: 64 characters, up to 12 fractional decimal places, exponent -18 to 18, absolute value at most 10^18. JSON output: 16,000 bytes. Inputs and results are neither stored nor sent.

Statistics

Try a use case and check the result

Use a zero weight and a one-value dataset to distinguish ordinary means, weighted means and sample metrics.

Example buttons replace the inputs and settings above and calculate. Restore previous input steps back one example at a time. After trying multiple examples, repeat restore to return to your original input. This history is lost when the page closes.

A zero weight still counts in the ordinary mean

Input and settings

Values: 10 100 / Weights: 1 0

Expected result

Count 2 / Mean 55 / Median 55
Weight sum 1 / Weighted mean 10

One value has no defined sample variance

Input and settings

Values: -5 / Weights: empty

Expected result

Count 1 / Mean and median −5 / Population variance and deviation 0
Sample variance and deviation: undefined (JSON null)

How to read the result

The ordinary mean is (10+100)÷2=55. The weighted mean is (10×1+100×0)÷1=10. Weights affect only the weighted mean: count, median and ordinary variance still include zero-weight values. Population variance divides by n and sample variance by n−1, so the one-value sample metrics are undefined rather than zero.

Scope and limits

Separate values and optional weights with whitespace. Each input is limited to 1,000,000 UTF-8 bytes; values to 10,000; each number to 64 characters, magnitude 10¹⁸, effective twelve-place fractional precision and exponent −18 to 18. Weights must match the value count, be non-negative and have a positive sum. Results round to twelve decimal places; JSON is capped at 16,000 bytes. A tiny variance may round to zero while deviation from the unrounded variance remains positive. Weighted variance and confidence intervals are not calculated.

Verification: hand calculations give 55 and 10. Existing functions check null sample metrics for one value and rejection of mismatched/all-zero weights. Browser checks cover real Worker output, JSON downloads and restoration after two examples.

Continue with the next task

Details and limits

For the example 1, 2, 3, 4, mean and median are 2.5, population variance is 1.25, and sample variance is about 1.666666666667. Weights 1, 1, 2, 2 give a weighted mean of about 2.833333333333.

Population variance divides the sum of squared deviations by n; sample variance divides by n−1. Their square roots are the population and sample standard deviations. With one number, sample variance and sample standard deviation are unavailable and become null in JSON.

Weighted mean divides the sum of number × weight by the sum of weights. Weights must be nonnegative and their sum must be positive. Leave weights empty for ordinary statistics; weight sum and weighted mean then become null. Ordinary mean, variance and standard deviation do not use the weights.

Decimals are scaled to integers for exact aggregation. Results are rounded to at most 12 decimal places; exact halfway cases round away from zero. Trailing zeros are omitted. JSON numeric results are decimal strings to retain precision; only count is a JSON number. Standard deviations use the exact variance before rounding.

Editing cancels in-progress work and clears the old result. Cancel retains the inputs; Reset clears numbers, weights and result. JSON is saved as UTF-8 without a BOM or added trailing newline.

Frequently asked questions

Which standard deviation should I use?

Use population standard deviation for the entire population and sample standard deviation for a sample from a larger population. Sample statistics need at least two numbers.

Is weighted mean calculated separately?

Yes. Ordinary statistics give every input equal weight. Weighted mean uses the corresponding weights separately. A zero-weight number still participates in ordinary statistics.

What happens outside the numeric limits?

The tool reports an error instead of silently rounding the input. Exponent notation has the same magnitude and fractional-place limits. Thousands separators such as 1,000 are not accepted.

Related tools

Inputs and storage

Keep any content you need before clearing. This tool does not autosave inputs or results. Reloading or closing the page, clearing inputs or resetting may discard your work.

Favorites and language preferences are stored separately and may be lost when site data is cleared. Tool resets and site-data deletion do not delete files already downloaded to your device.

Explore tools & games

All 120 tools · 16 games

All 120 tools · 16 games

Text & writing 26

Calculators & converters 22

Date & time 12

Images & PDF 26

Data & web 28

Random & handy 6

Games 16