Statistics Reference

n vs n−1: Why Sample Variance Divides by n−1

The strangest-looking rule in introductory statistics — divide by n−1, not n — is neither a convention nor a fudge. It repairs a real, provable bias: deviations measured from a sample's own mean systematically come up short. This guide shows where the bias comes from, verifies the fix on a population small enough to check every case by hand, and lists the situations where plain n is actually correct.

The Two Formulas

Population variance

σ² = Σ(x − μ)² / N

Use when the data is the complete group and μ is its true mean. Nothing is being estimated, so nothing needs correcting.

Sample variance

s² = Σ(x − x̄)² / (n − 1)

Use when the data is a sample and the goal is the variance of the population it came from. The n−1 is Bessel's correction.

The numerators look identical but hide the whole story: the population formula measures distance from the true mean μ, while the sample formula can only measure distance from the sample's own mean x̄ — and that substitution is what creates the bias.

Why Deviations Come Up Short

The sample mean is not an innocent bystander — it is computed from the same values it is then compared against. Among all possible reference points, x̄ is the one that makes the sum of squared deviations as small as it can possibly be. Whenever x̄ misses the true mean μ (which is almost always), squared deviations measured from x̄ are strictly smaller than the ones measured from μ. The shortfall is not random noise that averages away; it is a systematic underestimate, and its exact expected size is one σ² out of n:

E[Σ(x − x̄)²] = (n − 1)σ²

Dividing by n−1 instead of n exactly cancels the shortfall, which is the definition of an unbiased estimator: right on average across repeated samples.

The degrees of freedom view says the same thing without algebra. The n deviations from x̄ always sum to zero, so once n−1 of them are known, the last is forced. Only n−1 independent pieces of information about spread exist, and the honest average divides by the information actually available. The same logic later explains why a t-distribution with n−1 degrees of freedom appears whenever s replaces σ.

Verify It Yourself: A Four-Value Population

Take the population {2, 4, 6, 8}: its true mean is μ = 5 and its true variance is σ² = (9 + 1 + 1 + 9)/4 = 5. Now draw samples of size n = 2 with replacement — there are only 16 equally likely ordered samples, so the “average over repeated samples” can be computed exactly, not simulated.

For a two-value sample, the sum of squared deviations around the sample mean simplifies to (x₁ − x₂)²/2. Averaging it over all 16 samples:

  1. The 16 squared differences (x₁ − x₂)² average to exactly 10 (four zeros on the diagonal, then 4, 16, 36 appearing symmetrically — total 160/16).
  2. So the average sum of squares is 10/2 = 5.
  3. Divide by n−1 = 1: average estimate = 5 — exactly σ². Unbiased.
  4. Divide by n = 2: average estimate = 2.5 — half the truth, matching the general shortfall factor (n−1)/n = 1/2.

No appeal to authority needed: with n = 2, dividing by n underestimates the variance by 50% on average, and Bessel's correction repairs it exactly.

The Familiar Example, Both Ways

For the dataset 4, 8, 6, 5, 12 (mean 7, sum of squared deviations 40):

Treating the data as…VarianceStandard deviation
A complete population (÷ n = 5)40 / 5 = 8√8 ≈ 2.8284
A sample (÷ n−1 = 4)40 / 4 = 10√10 ≈ 3.1623

A 25% difference in variance from the same five numbers — entirely a statement about what question is being asked. The variance calculator and standard deviation calculator report both versions side by side for exactly this reason.

When Plain n Is the Right Choice

  • True populations. If the 30 students in one class are the entire group under discussion, their variance uses n = 30. No inference, no bias to correct.
  • Known mean. In the rare case the true μ is known independently and deviations are measured from it, dividing by n is already unbiased — the correction exists only because x̄ was estimated.
  • Some model-fitting contexts. Maximum likelihood estimation under a normal model produces the n version; statisticians accept its small bias in exchange for other properties. Software in this tradition (some ML libraries) defaults to n — worth checking before comparing outputs.

Try the Variance Calculator

Compute population and sample variance side by side, with every deviation and squared term shown.

Frequently Asked Questions

When should I divide by n and when by n - 1?

Divide by n when your data is the entire population you care about (every student in the class, every unit produced today) - you are describing, not estimating. Divide by n - 1 when the data is a sample used to estimate the variance of a larger population - the correction removes the systematic underestimate that comes from measuring deviations around the sample mean.

Why exactly n - 1 and not n - 2 or some other correction?

Because exactly one degree of freedom is spent estimating the mean. Once the sample mean is fixed, the n deviations must sum to zero, so only n - 1 of them can vary freely. The algebra confirms it: the expected value of the sum of squared deviations around the sample mean is exactly (n - 1) sigma-squared, so dividing by n - 1 - and nothing else - makes the estimator unbiased.

Does the difference between n and n - 1 matter for large samples?

Less and less. The two estimates differ by the factor n/(n - 1): about 11% for n = 10, 1% for n = 100, and 0.1% for n = 1000. The correction matters most for small samples - exactly where estimating variance is hardest. With five values, dividing by 4 instead of 5 changes the answer by 25%.

Is the sample standard deviation unbiased after Bessel's correction?

No - a subtle and often-skipped point. Bessel's correction makes the sample VARIANCE unbiased, but the square root of an unbiased estimator is not itself unbiased: the sample SD still slightly underestimates sigma on average (the square root function bends downward, so E[sqrt(X)] < sqrt(E[X])). The remaining bias is small and shrinks with n, and in practice the n - 1 standard deviation is the standard reported value.

What is the difference between VAR.P and VAR.S in Excel (or STDEV.P and STDEV.S)?

The P versions divide by n (population formulas); the S versions divide by n - 1 (sample formulas). Excel, Sheets, and most statistical software default their generic functions to the sample version. If a spreadsheet and a textbook answer disagree by a factor of about n/(n - 1), a P/S mismatch is almost always the reason.

Which version do calculators and statistical software use by default?

Almost all inferential software defaults to n - 1, because data fed to statistics tools is nearly always a sample. The variance and standard deviation calculators on this site compute both and label them explicitly, which is the safest practice: report which denominator you used whenever the sample is small.