Statistics Calculator
Calculate mean, median, mode, standard deviation, variance and more.
Reviewed by Aygul Dovletova · Last reviewed
Running the Statistics Calculator
- Paste or type your dataset into the main textarea. The parser splits on commas, semicolons, tabs, spaces, and newlines, so CSV snippets, spreadsheet selections, and newline-separated logs all work.
- Watch the summary panel update as you type. Count, sum, mean, median, mode, range, min, max, variance, and standard deviation are recomputed on every input event.
- Check the mode line if your data has ties: the panel shows every value tied for highest frequency, not a single arbitrary winner.
- Copy a result by clicking the value; it drops into your clipboard ready for a report or spreadsheet cell.
- Clear with the Clear button when you want to start over; closing the tab also discards everything.
How the Numbers Are Computed
Mean is a straight sum divided by count. Median sorts a copy of the array with the default numeric .sort((a, b) => a - b) comparator and takes the middle element (or the average of the two middle elements for an even count). Mode uses a Map<number, number> to count occurrences in one pass, then scans the map for the maximum frequency. Range is max - min, both obtained with Math.max(...arr) and Math.min(...arr).
Variance uses Welford's online algorithm rather than the naive two-pass sum((x - mean)²) / n. Welford updates a running mean and running sum-of-squared-deviations in one sweep and avoids the catastrophic cancellation that the textbook formula suffers when values are large and close together (a well-known gotcha described by Donald Knuth in The Art of Computer Programming, Volume 2). Standard deviation is then just Math.sqrt(variance). All computation happens inside the component; no data leaves the browser, no analytics event carries your numbers, and there is no server-side fallback.
Real Situations That Call For Quick Stats
- Summarising survey responses from a Google Form export before dropping them into a slide.
- Computing the average and standard deviation of cycle times from a CI system to decide whether a flaky test is actually slow.
- Checking whether the mean and median of a salary dataset disagree, which is a quick tell for skew.
- Sanity-checking a pandas result in a notebook by pasting the values here.
- Teaching a descriptive-statistics lesson where showing the formulas update live is more useful than static slides.
- Auditing an A/B experiment sample where you want to eyeball whether the variances look similar before running a t-test.
Edge Cases to Watch
- Single-value datasets have variance 0 and standard deviation 0; the tool shows exactly that rather than an error.
- All-equal datasets list every value as the mode because every value ties for highest frequency; this matches Karl Pearson's original definition.
- Empty input produces nothing; the panel stays blank rather than dividing by zero and reporting NaN.
- Scientific notation like
1.5e3is parsed byNumber(), so1.5e3equals1500. - Very large values can cause the naive sum to lose precision after about 1015 in double-precision arithmetic; for extremely long datasets use Kahan summation or a pandas pipeline.
- Negative numbers work unchanged because variance is based on squared deviations; the sign drops out.
- Non-numeric tokens are skipped silently rather than halting parsing, which is forgiving for pasted logs but means a typo will not be flagged.
Population vs. Sample and the Dispute Over (n-1)
This tool reports the population variance (divided by n) and population standard deviation. If you treat your data as a sample drawn from a larger population and want an unbiased estimate of the population variance, divide the displayed variance by (n - 1) / n; this is Bessel's correction, justified by the fact that the sample mean is itself estimated from the data and therefore consumes one degree of freedom. For small samples (n < 30) the difference is material and statistics textbooks uniformly recommend the sample formula. For large n the two converge. The convention of dividing by n versus n-1 is also why spreadsheet users often find VAR.P and VAR.S disagree; both are defined in the ISO/IEC 80000-2 vocabulary for quantities and units, part 2.
When a Dedicated Stats Package Beats a Quick Tool
This calculator handles descriptive statistics; anything inferential - confidence intervals, t-tests, ANOVA, regression - belongs in R, Python (scipy.stats, statsmodels), Julia, or a dedicated platform like JASP or Stata. Spreadsheets (Excel, Google Sheets, Numbers) offer AVERAGE, MEDIAN, STDEV.P, STDEV.S, and a full charting layer, but they punish datasets above a few hundred thousand rows. Command-line options like datamash, awk, or jq are excellent for piping. The browser tool wins when you have a modest dataset, need the answer in under five seconds, and do not want to open anything heavier.
Frequently Asked Questions
Is this population standard deviation or sample standard deviation?
The tool reports the population standard deviation, which divides the sum of squared deviations by <em>n</em>. If you are working with a sample and want the unbiased sample standard deviation, multiply the displayed variance by <em>n</em>/(<em>n</em>-1) before taking the square root, or equivalently divide the sum of squared deviations by <em>n</em>-1. The two converge for large datasets but disagree meaningfully when <em>n</em> is under 30.
Why does the tool use Welford's algorithm instead of the textbook formula?
The naive two-pass formula <code>variance = sum((x - mean)²) / n</code> requires the full mean before it can start accumulating squared deviations, and it suffers catastrophic cancellation when the values are large and close together. Welford's 1962 algorithm updates a running mean and a running sum of squared deviations in one pass using a numerically stable recurrence. Knuth describes it in <em>TAOCP</em> Vol. 2, and every serious stats library uses it or a variant internally.
Does my data ever leave the browser?
No. The calculator is a client-side Preact component, and the parser, summariser, and Welford accumulator all live in that component. There is no fetch call to a backend, no analytics event attached to your dataset, and no localStorage write. You can paste sensitive data (salary figures, medical measurements, proprietary metrics) with the same confidence as pasting into a desktop app.
What does the calculator do when every value appears exactly once?
Strictly speaking every value is tied for highest frequency, so there is no unique mode. Different textbooks handle this differently: some say there is no mode, others say every value is a mode. This tool takes the second, more literal view and lists all values. If you see a huge mode list, that is the signal that your data has no repeat.
How does median get computed for an even number of values?
The tool sorts the values ascending and takes the arithmetic mean of the two middle elements. For <em>n</em> = 6 that is <code>(sorted[2] + sorted[3]) / 2</code>, using zero-based indexing. This matches the definition used by <code>numpy.median</code>, <code>R</code>'s <code>median()</code>, and ISO 80000-2. Some older textbooks pick the lower of the two instead, which the tool does not do.
Can I paste a CSV column directly?
Yes. The parser splits on any of commas, semicolons, tabs, spaces, and newlines, and tolerates mixed delimiters, so a single-column CSV paste from a spreadsheet or a newline-separated log both work. Values that fail <code>Number()</code> are silently ignored, so a header row like "value" at the top of the paste will be skipped instead of crashing the count.
What is the practical upper limit on dataset size?
Somewhere north of a million values per run is handled comfortably on a modern laptop; the bottleneck is the copy-to-sort step for the median rather than the Welford pass. For datasets larger than that, or for streaming situations where you cannot hold everything in memory, switch to a tool that can work incrementally (pandas with chunked reads, DuckDB, or <code>awk</code>) or roll a server-side summary.
Why does the sum sometimes look off by a few decimal places?
IEEE 754 double-precision floating point has 52-bit mantissa resolution (about 15 to 17 decimal digits). Summing thousands of numbers with fractional parts can accumulate enough rounding error that the displayed sum deviates from the true mathematical sum by a few ULPs. Welford's algorithm controls this for the variance; for the sum itself a Kahan summation would eliminate it entirely but at a small performance cost.
What is the difference between range, variance, and standard deviation?
Range is the single number <code>max - min</code>, useful but highly sensitive to outliers. Variance is the average squared deviation from the mean, expressed in the square of the original unit. Standard deviation is the square root of variance, back in the original unit, and is the usual measure of spread because it is directly comparable to the mean. Together they give three increasingly informative views of how spread out the data is.
Can I get quartiles and percentiles from this tool?
Not in the current build. The panel shows the five measures of central tendency plus spread metrics (variance, standard deviation, range) but does not compute Q1, Q3, the interquartile range, or arbitrary percentiles. Those live in a separate statistical summary tool, or you can get them from <code>numpy.percentile</code> or a spreadsheet function like <code>QUARTILE.INC</code>.
Is the sort stable for duplicate values?
Sort stability does not affect the results because equal values are indistinguishable for median, mode, min, and max. V8, SpiderMonkey, and JavaScriptCore all use stable sorts in modern versions.
Can I use this as a median age calculator from a list of ages?
Yes. Paste the ages as a comma- or newline-separated list and the median row gives the central age in seconds, no special "median age calculator" branding required. For a sample of 17 ages it is the 9th value in sorted order; for an even count it is the mean of the two middle values. Use the same input box for any other midpoint statistic - median income, median response time, median sentence length - because the formula is the same.
Is this approachable enough for an elementary statistics course?
It is built for elementary statistics use. Mean, median, mode, range, variance, and standard deviation are the six descriptive measures that appear in every introductory textbook, and the panel labels them in the same order. Students can paste a small dataset, see all six side by side, and verify hand calculations. For inferential statistics - confidence intervals, hypothesis tests, regression - move to a dedicated package like R or Python because that level of analysis is out of scope here.
More Math & Calculators
Age Calculator
Calculate exact age in years, months and days from a birthdate.
Open toolArea & Volume Calculator
Calculate area of 2D shapes and volume of 3D solids.
Open toolBMI Calculator
Calculate your Body Mass Index and find your weight category.
Open toolByte / Bit Converter
Convert between bits, bytes, KB, MB, GB, TB and PB.
Open toolDiscount Calculator
Calculate discount amount, sale price, savings, and discounted value with optional sales tax. Supports stacked coupons.
Open toolFibonacci Sequence Generator
Generate Fibonacci numbers up to any length.
Open tool