Calcylator
Variance

Variance and standard deviation:
when to divide by n and when by n − 1

Pick the right divisor before you quote a spread. The only question is whether your numbers are the whole group or a slice of it.

Calcylator Editorial Team

Updated · 6 min read

Whole group or a slice: the choice that decides the divisor

Variance and standard deviation both measure how far values wander from their average. The formulas for the two versions are almost identical, and the single difference is the number you divide by at the end: n for a population, n − 1 for a sample.

A population is every item you care about. Marks of all 40 students in one class, if the question is about that class only, form a population. A sample is a subset used to say something about a bigger group: 40 students picked from a school of 2,000 are a sample, because you want to describe the school, not just those 40.

Most real data sets are samples, even when they feel complete. Last month's sales are the whole of last month, but if you want to describe how sales typically behave, they are a sample of the shop's long-run behaviour. When in doubt, the sample version is the safer default, and it matters most when n is small.

The formulas side by side

Start by finding the mean, then measure each value's distance from it, square those distances so negatives do not cancel, and add them up. That total is the sum of squared deviations. Dividing it by n gives the population variance; dividing by n − 1 gives the sample variance.

Population variance =Σ (x − μ)²N
x:
each value
μ:
population mean
N:
number of values in the population
Sample variance =Σ (x − x̄)²n − 1
x̄:
sample mean
n:
number of values in the sample
n − 1:
degrees of freedom
Standard deviation =√variance
σ:
square root of the population variance
s:
square root of the sample variance
Standard deviation is back in the original units, which is why it is quoted more often than variance.

Variance is in squared units, so a spread in rupees gives a variance in rupees squared. Taking the square root returns to rupees, which is easier to compare with the data itself.

Six numbers worked through both ways

Take six daily delivery counts: 4, 8, 6, 5, 3 and 7. The mean is 33 ÷ 6 = 5.5. Subtract the mean from each value to get −1.5, 2.5, 0.5, −0.5, −2.5 and 1.5, then square them: 2.25, 6.25, 0.25, 0.25, 6.25 and 2.25.

  • Data

    4, 8, 6, 5, 3, 7

  • Mean

    5.5

  • Sum of squared deviations

    17.5

  • Population variance (÷ 6)

    2.917

  • Sample variance (÷ 5)

    3.5

  • Population SD

    1.708

Sample standard deviation

1.871

Same data, same sum 17.5; only the divisor changes, and the sample version is about 20% larger here.

Notice that the sample figure is always larger than the population figure for the same numbers, by the ratio n ÷ (n − 1). With six values that is 6/5, or 20%. With 600 values it would be about 0.17%, which is why the distinction fades for big data sets.

Why the sample version uses n − 1

A sample's own mean sits, by construction, in the middle of that sample. The values are therefore closer to their own mean than they are to the true population mean, so the squared distances come out too small. Dividing by n would, on average, understate the real variance.

Using n − 1 corrects for that. This adjustment is known as Bessel's correction. One way to see it: once the sample mean is fixed, only n − 1 of the deviations are free to vary, because the last one must make the total zero. Those n − 1 free pieces are the degrees of freedom.

The effect is visible with two values. Take 2 and 8: the mean is 5 and the squared deviations add up to 18. Dividing by 2 gives 9, but a single pair gives very little information about spread, and dividing by 1 gives 18. With so few points the honest answer is a large and uncertain one.

One subtlety: the correction makes the sample variance unbiased, but the square root of it, the sample standard deviation, is still slightly low on average. For most practical work that residual bias is ignored.

What a standard deviation tells you in practice

A standard deviation has no meaning on its own until it is set against the mean. For data that is roughly bell-shaped, about 68% of values fall within one standard deviation of the mean, about 95% within two, and about 99.7% within three. This is the 68–95–99.7 rule, and it gives the number a physical feel.

If delivery times average 40 minutes with a sample SD of 5 minutes, most deliveries (around two-thirds) land between 35 and 45 minutes, and nearly all of them between 30 and 50. The rule applies only to roughly symmetric, single-peaked data, so check the shape before leaning on it.

Variance has one property that standard deviation lacks: for independent quantities, variances add. If the preparation time has variance 16 and the travel time has variance 9, the total time has variance 25, so an SD of 5, not 4 + 3 = 7. This is why variance is the working quantity inside statistical formulas, while standard deviation is the one people read.

Which one to use in practice

SituationUseReason
Every item is in your list (all 12 monthly bills of one year, if that year is the question)PopulationNothing is being estimated
A survey, a test batch, a few weeks of readingsSampleYou are estimating a larger group
Quality checks on 30 units from a production runSampleInference about the whole run
Exam marks of one class, reported for that class onlyPopulationThe class is the whole group
UnsureSampleSlightly larger, so it errs on caution

If the data set is huge, the choice barely changes the answer, so do not agonise over it. The decision matters when you have fewer than about 30 values, where the gap can be 3% or more.

Common slips when working it out by hand

  • Forgetting to square the deviations, so positives and negatives cancel and the total comes out near zero.
  • Squaring each raw value instead of each deviation from the mean.
  • Mixing the two divisors, for example dividing by n − 1 but then calling it a population figure.
  • Quoting variance as if it were in the data's own units; only the standard deviation is.
  • Rounding the mean early. Keep a few extra decimals until the final step.

A quick check: standard deviation can never be negative, and it is zero only when every value is identical. If your result is negative, a square root or a subtraction went wrong.

Common questions

What is the difference between variance and standard deviation?

Variance is the average squared distance from the mean, in squared units. Standard deviation is its square root, in the same units as the data. For the numbers 4, 8, 6, 5, 3, 7 the sample variance is 3.5 and the SD is about 1.87.

Why do we divide by n − 1 for a sample?

A sample's values sit closer to their own mean than to the true population mean, so dividing by n understates the spread. Using n − 1 corrects that on average. It is called Bessel's correction.

When should I use population standard deviation?

Use it when your list contains every item you want to describe, such as the marks of one class for that class alone. If the numbers are a sample drawn to represent a larger group, use the sample version.

Is sample variance always bigger than population variance?

Yes, for the same numbers the sample figure is larger by the factor n ÷ (n − 1). With 6 values that is 20% larger; with 100 values it is about 1% larger, and the gap shrinks as n grows.

Can variance or standard deviation be negative?

No. Both come from squared distances, which are never negative, so the smallest possible value is zero. That happens only when every value in the data is exactly the same.

Was this guide helpful?

Continue reading

View all blogs