Sample and population variance — and an experiment that settles the divisor.
Variance, and the divisor argument settled by experiment
Paste numbers separated by commas, spaces or new lines.
Is your data a sample or the whole population?
Almost always this one. Excel VAR / VAR.S, R var(), and every "sample variance" in a textbook.
Σ(x − x̄)² = 2,350.92, n = 12
213.7197
Divided by n − 1 = 11. The standard deviation is its square root, 14.6192, which is the version in the units of your data.
Variance
213.7197
s² (÷ n−1)
Standard deviation
14.6192
√variance, in your units
Mean
65.0833
every deviation is measured from here
Sum of squares
2,350.92
Σ(x − x̄)², before dividing
The other divisor, for comparison
Dividing the same sum of squares by N = 12 instead gives 195.9097 — 8.3% smaller. That gap is what Bessel’s correction is for.
Why n − 1? Run the experiment
Twenty thousand samples of this size, drawn from a population whose variance really is 1.
Average of each estimator over 20,000 samples of size 5, against a true variance of 1.
Divisor
Average estimate
Share of the truth
Theory says
÷ n (biased)
0.8006
80.1%
80.0%
÷ n − 1 (Bessel)
1.0007
100.1%
100.0%
At n = 5, dividing by n leaves the estimate 20.0% low on average — not sometimes, on average, forever. Dividing by n − 1 removes exactly that. Step the sample size up and watch the gap close.
What this tool shows
“Divide by n − 1 to correct for bias” is usually where the explanation stops. The panel in the tool runs the experiment instead — twenty thousand samples from a population whose variance is known — so you can watch the wrong divisor land 20% low at n = 5 and see the gap close as the sample grows.
Sample variance with the n − 1 divisor
Population variance with the N divisor
Both shown together for comparison
A live simulation of why n − 1 is used
How to tell which divisor you need
Why the square root is still biased
Bessel, simulated Sample and population Matches Excel VAR.S Sources cited
Updated 7 September 2026 · Works in any browser, no installation
Average the squared distances from the mean. Divide the sum of squares by n − 1 for a sample and by N for a population. The whole difficulty of the topic is that one subtraction, and it exists for a reason you can measure rather than memorise.
At a glance
Formula shown
Sample variance s² = Σ(xᵢ − x̄)² / (n − 1). Population variance σ² = Σ(xᵢ − μ)² / N. The numerator is identical; only the divisor differs.
Scenario support
Reporting the spread of measurements; feeding a t-test, ANOVA or confidence interval, all of which take variance as input; comparing the consistency of two processes; sizing a portfolio's risk, where variances of independent holdings add.
Educational estimate
Planning support from the values you enter — not professional advice.
What squaring buys, and what it costs
The obvious way to measure spread is to average how far each value sits from the mean. That obvious way fails immediately, and the failure is instructive.
Raw deviations always sum to exactly zero. Not approximately — exactly, by the definition of the mean. Every dataset would have an average deviation of zero, which measures nothing at all.
So you need to remove the signs. There are two sensible ways: take absolute values, or square. Both work, and statistics went with squaring.
What squaring buys. A squared function is smooth and differentiable everywhere, which means it can be minimised with calculus — and that is the whole foundation of least squares, regression and analysis of variance. Absolute values have a corner at zero and are far less tractable. Squaring also makes variances of independent quantities simply add, which absolute deviations do not do.
What squaring costs. Two things. The result is in squared units, so the variance of a set of heights in centimetres is in square centimetres, which is not a quantity anyone can picture. And squaring gives distant points disproportionate weight: a value ten times further out contributes a hundred times as much, so one bad observation can dominate.
Both costs have answers. Take the square root and you have the standard deviation, back in the original units. Use the interquartile range instead and the outlier sensitivity goes away entirely, at the price of ignoring half your data.
The n minus 1 question, settled by experiment
Here is the actual reason, and it is not arbitrary.
When you compute a variance you measure every deviation from the sample mean, because the population mean is exactly the thing you do not know. And the sample mean is, by construction, the point that makes the sum of squared deviations as small as it can possibly be for that data.
So the sum of squares you compute is systematically too small. Not sometimes — always, in expectation. Measured from the true mean it would have been larger. Dividing by n inherits that shortfall and gives an estimate that is on average too low by a factor of exactly (n − 1)/n.
That is the number the panel in the tool checks. At n = 5 the factor is 4/5, so the naive estimate lands 20% low on average; at n = 100 it is 99/100 and the shortfall is 1%. Dividing by n − 1 instead multiplies by exactly the reciprocal and cancels it.
The degrees of freedom framing says the same thing differently. The n deviations are not n independent pieces of information, because they are forced to sum to zero. Tell me any n − 1 of them and I can compute the last. There are only n − 1 free values, and the divisor counts free values rather than observations.
It is worth being clear that this is a statement about averages over many samples, not about your dataset. For any single sample the n − 1 version might be further from the truth than the n version. What it guarantees is that it is not wrong in a consistent direction, and systematic error is the kind that does not wash out no matter how much data you collect.
The bit that stays biased, which nobody mentions
This follows directly from the last section and is left out of almost every course.
Bessel’s correction makes the variance unbiased. It does not make the standard deviation unbiased.
The reason is a general fact about square roots: the square root of an unbiased estimator is not itself unbiased. The square root is a concave function, and by Jensen’s inequality the average of the roots is less than the root of the average. So s, the sample standard deviation, underestimates the population standard deviation on average — even though s² estimates the population variance perfectly.
The size of it is small and shrinks fast: roughly a 5% underestimate at n = 3, about 1% at n = 10, and negligible past n = 30. There is an exact correction factor, usually written c₄, and quality-control charts do apply it — which is why control-chart constants exist as published tables.
For most purposes it does not matter, and nobody is suggesting you correct for it. It is worth knowing for one reason: if someone tells you s is an unbiased estimate of σ, that is not true, and the confident version of the claim is the one to be suspicious of.
Why variance exists when the standard deviation is friendlier
A reasonable question: if variance is in unreadable squared units and the standard deviation is in real ones, why is variance quoted at all?
Because variances add and standard deviations do not. For two independent quantities, the variance of their sum is the sum of their variances. That single property is why variance is the quantity the mathematics is written in.
A concrete version. Two independent measurements each have a standard deviation of 3. The variance of each is 9, so the variance of their sum is 18, and the standard deviation of the sum is √18 ≈ 4.24. It is not 6. Standard deviations combine in quadrature, and adding them directly overstates the combined spread every time.
This is the engine behind a great deal of applied statistics. It is why the standard error of a mean is σ/√n — the variance of a sum of n independent observations is nσ², dividing by n gives σ²/n, and the square root gives the familiar formula. It is why independent risks diversify in a portfolio. It is why analysis of variance is called that: the whole method rests on splitting a total variance into parts that add up.
The practical rule: do the arithmetic in variances, then take the square root at the very end when you want a number a reader can interpret.
The additivity holds only for independent quantities. When they are correlated a covariance term appears, and the sum can be larger or smaller than the parts — which is exactly the mechanism behind diversification.
Sample or population: how to actually tell
The question is not how much data you have. It is what you want the number to describe.
Use the population divisor N only when the values in front of you are the entire group you care about, and you have no interest in generalising. The exam marks of the thirty students in one class, when the question is about that class. Every match a player has played, when the question is about that record.
Use the sample divisor n − 1 whenever your data stands in for something larger — which is nearly always. Thirty measurements from a process that will keep running. A survey of a thousand people meant to describe a country. Last quarter’s response times, if you intend to say anything about next quarter’s.
The everyday test: would collecting more data make sense? If yes, you have a sample, and n − 1 is right. If the idea is meaningless because you already have everything, it is a population.
A common trap is treating a large dataset as a population because it feels exhaustive. Ten million transactions is still a sample if you are drawing conclusions about transactions in general. It barely matters numerically at that size — the divisors differ by one part in ten million — but it matters for saying honestly what the number means.
When in doubt, use n − 1. On large samples the difference is invisible, and on small ones it is the one more likely to be right.
The shortcut formula that quietly loses precision
Textbooks give a “computational formula” that avoids computing the mean first: Σx² − (Σx)²/n. It is algebraically identical to the definition, and on a computer it is genuinely dangerous.
The problem is catastrophic cancellation. Both terms are large and nearly equal when the data sits far from zero, and subtracting two nearly-equal large numbers destroys the significant digits of the small difference that survives.
Take four values around a billion that differ by 1 each. Their true variance is small. But Σx² is around 4 × 10¹⁸, well past the roughly sixteen significant digits a double-precision float carries, so the information distinguishing those values is gone before the subtraction happens. The formula can return zero, or even a negative variance — which is impossible for a sum of squares and is a clear sign the arithmetic has failed.
The definition does not have this problem, because subtracting the mean first brings every value near zero and keeps the squares small. This page computes it that way: mean first, then deviations, then squares.
If you cannot make two passes over the data — a stream, or a dataset too large to hold — the answer is not the shortcut formula but Welford’s algorithm, which updates the mean and the sum of squares together in one pass and is numerically stable. It is what serious statistical software uses, and it is the right thing to reach for when the two-pass version is not available.
Sources and methodology
Where the correction and the numerical caution come from.
Method. Variance is computed from the definition — mean first, then deviations, then squares — and not from the Σx² shortcut, for the numerical reason set out above. The Bessel panel is a real simulation rather than a rendered formula: it draws twenty thousand samples of the chosen size from a normal population of known variance and averages both estimators. The generator is seeded, which is required rather than tidy — this component renders on the server and again in the browser, and an unseeded draw would be a hydration mismatch. The suite asserts that the biased estimator converges on (n − 1)/n across six sample sizes, with a tolerance derived from the Monte Carlo standard error σ²√(2/((n−1)T)) rather than hand-picked; an earlier hand-picked band failed against a correct engine, which is why it is derived now. That engine is verified on every change against 44 assertions. The count and the per-case breakdown are published on the formula verification page.
Related calculators
Where this goes next:
Standard DeviationSample and population standard deviation, plus variance, mean, median, quartiles, z-scores, outliers, and confidence intervals.
IQRInterquartile range, the 1.5 × IQR outlier fences, and exactly which values fall outside — with a slider that corrupts one value so you can watch the range move while the IQR does not.
QuartileQ1, Q2 and Q3 by all eleven conventions in common use — Excel, R, Tukey hinges and the TI-84 rule — with a warning when they disagree.
Five Number SummaryMinimum, Q1, median, Q3 and maximum, drawn as a box plot with every one of your observations plotted underneath it — so you can see what the summary threw away.
PercentileThe value at any percentile and the percentile rank of any value, with all nine standard methods — and the round trip that shows the two directions are not inverses.
Weighted AverageEach value carries the weight you give it, with every item's share of the total shown as a percentage so you can see what is actually driving the answer.
An educational tool. Variance describes the sample you enter; treating it as the population value is an inferential step with its own uncertainty that this page does not quantify.
Published a variance calculator that answers the n-1 question by running the experiment instead of asserting the result: 20,000 samples drawn from a population of known variance, both estimators averaged, against the factor theory predicts.
The simulation is seeded rather than random, which is required and not tidiness — the component server-renders and then hydrates, and an unseeded draw would be a mismatch. Tolerances in the suite are derived from the Monte Carlo standard error rather than hand-picked, after a hand-picked band failed against a correct engine.
States two things courses routinely omit: Bessel's correction leaves the standard deviation biased even though it fixes the variance, and the Sigma-x-squared shortcut formula loses precision catastrophically on data far from zero.
Add this calculator to your site
Responsive embed — and private: nothing your visitors type leaves their browser.