Variance
Two archers each fire five arrows. Both average dead-centre — same
mean. But one groups
every arrow in a tight cluster, while the other sprays them all over the target. The averages
can't tell them apart; only their spread can. The
range is one
way to measure that spread — but the range looks only at the two most extreme arrows, so a single
wild shot wrecks it and the other eight arrows have no say at all.
Variance does something far more honest: it asks how far every data
point sits from the mean, and averages those distances. Every point votes. It is the workhorse
measure of spread — the one nearly all of statistics is quietly built on.
For data x_1, x_2, \dots, x_n with mean \bar{x}:
\sigma^2 = \frac{1}{n}\sum_{i=1}^{n}\left(x_i - \bar{x}\right)^2.
Each term (x_i - \bar{x}) is a deviation — how far
that one point strays from the centre. Variance is the average squared
deviation.
The recipe, in four steps
Every variance is cooked exactly the same way:
- Find the mean \bar{x} of the data.
- For each value, take its deviation x_i - \bar{x}.
- Square every deviation.
- Average the squares.
That average of squares is the variance. The two ideas that make it work — why we
square, and how big deviations get punished — are worth pausing on.
Why square? Because raw deviations cancel
It is tempting to just average the deviations themselves. But that always gives zero — the
mean sits exactly at the balance point, so the points below it cancel the points above:
\sum_{i=1}^{n}\left(x_i - \bar{x}\right) = 0 \quad\text{always.}
Squaring fixes the sign: a deviation of -3 and one
of +3 both contribute 9 instead of
cancelling. Squaring also punishes big misses — a point twice as far away
contributes four times as much — so variance is especially sensitive to far-flung values.
Worked example: five test scores
Five students scored 2,\ 4,\ 4,\ 5,\ 5 out of ten. Let's find the
variance step by step.
Step 1 — the mean.
\bar{x} = \frac{2+4+4+5+5}{5} = \frac{20}{5} = 4.
Step 2 & 3 — deviations and their squares.
\begin{array}{c|c|c}
x_i & x_i-\bar{x} & (x_i-\bar{x})^2 \\ \hline
2 & -2 & 4 \\
4 & 0 & 0 \\
4 & 0 & 0 \\
5 & 1 & 1 \\
5 & 1 & 1
\end{array}
Step 4 — average the squares.
\sigma^2 = \frac{4+0+0+1+1}{5} = \frac{6}{5} = 1.2.
Notice the two scores that are the mean contribute nothing — a zero deviation squares
to zero. Only distance from the centre counts.
A second example: spot the wider set
Compare \{4, 5, 6\} with \{1, 5, 9\}. Both
have mean 5, so the mean can't separate them — but the variance can.
\sigma^2_{\{4,5,6\}} = \frac{(-1)^2+0^2+1^2}{3} = \frac{2}{3} \approx 0.67,
\sigma^2_{\{1,5,9\}} = \frac{(-4)^2+0^2+4^2}{3} = \frac{32}{3} \approx 10.7.
The second set's variance is sixteen times larger, even though its points are
only four times farther out — that is the squaring, magnifying the gap and flagging the wider
set loud and clear.
Why square deviations rather than take their absolute value |x_i - \bar{x}|,
which also kills the sign? Two quiet reasons. First, x^2 is
smooth — you can differentiate it, and |x| has a
sharp corner at zero that calculus hates. Second, it turns out the mean is exactly the value that
minimises the total squared deviation: no other centre makes the sum of squares smaller.
That "minimise the sum of squares" idea is the seed of least-squares fitting,
which runs straight lines through scattered data all across science. Variance isn't an arbitrary
choice of formula — it is the natural companion of the mean.
See it: variance is the average square
The five points share a mean of 7 (the dashed line). Above each
point sits a square whose side is that point's distance from the mean, so its
area is the squared deviation (x_i - \bar{x})^2. Drag the
slider to spread the points out: the squares grow, and the reported variance — their average
area — climbs with them.
Notice the point sitting on the mean has a square of side zero: it adds nothing. Only
distance from the centre counts.
Population variance vs sample variance
There are two variances, and they differ only in what you divide by. When your data
are the whole story — every pupil in the class, every planet in the system — you have a
population, and you divide by n:
\sigma^2 = \frac{1}{n}\sum_{i=1}^{n}\left(x_i - \bar{x}\right)^2 \quad\text{(population)}.
But usually your data are just a sample — a handful drawn from a much larger
group you can't measure in full — and you want to estimate the spread of that larger group. Then
you divide by n-1 instead:
s^2 = \frac{1}{n-1}\sum_{i=1}^{n}\left(x_i - \bar{x}\right)^2 \quad\text{(sample)}.
The one-line reason: a sample's own mean is nudged toward the sample's own points, so measuring
spread from it under-counts the true spread — dividing by the smaller
n-1 nudges the estimate back up to compensate.
The units are squared too
Because we squared the deviations, the variance carries squared units. If the
data are heights in centimetres, the variance is in \text{cm}^2 — a
slightly awkward quantity to interpret. That single inconvenience is exactly what the
standard
deviation is built to repair.
- Variance is the average squared deviation from the mean: \sigma^2 = \dfrac{1}{n}\sum (x_i - \bar{x})^2.
- Raw deviations always sum to zero; squaring removes the sign so they no longer cancel, and makes large deviations count disproportionately.
- Its units are the square of the data's units — the reason the standard deviation takes a square root.
- A larger variance means the data are more spread out around the mean; a variance of 0 means every value equals the mean.
The commonest trap with variance is forgetting its units are squared. Measure
heights in centimetres and the variance comes out in \text{cm}^2 —
square centimetres — which is nonsense to picture: nobody is "1.2 square centimetres
tall". A variance of 36\ \text{cm}^2 does not mean the data
span 36 cm. That's why variance is rarely reported on its own; instead people take its square
root, the standard
deviation, which lands back in plain centimetres and can sit right next to the
original numbers.
It looks like a typo. To average five squared deviations, surely you divide by five? For a
sample, you divide by four — and this quiet n-1, called
Bessel's correction, has puzzled students for two centuries. Here's the
intuition. To measure spread you need a centre to measure from — but you don't know the true
centre of the big population, so you use the sample's own mean. That mean is computed
from the very points you're measuring, so it sits slightly closer to them than the true
mean would. The deviations come out a touch too small, and the naïve variance
under-estimates the real spread every single time. Shrinking the divisor from
n to n-1 inflates the answer by just the
right amount to cancel that bias. The "-1" is the price you pay for
having spent one piece of your data estimating the mean.
See it explained