Mathematics/Lessons/Measures of Location and Spread/Variance and Standard Deviation
Statistics · Measures of Location and Spread · Year 1

Variance and Standard Deviation

The most widely used measure of spread — because unlike the range or IQR, it takes every single value in the dataset into account.

10 min read 4 worked examples

Variance

The variance of a dataset measures the average squared distance of each value from the mean. For a raw dataset of $n$ values with mean $\bar{x}$:

$\text{Variance} = \dfrac{\displaystyle\sum (x-\bar{x})^2}{n}.$

Squaring the deviations before averaging stops positive and negative deviations from cancelling out (they'd otherwise sum to zero for any dataset), and it penalises larger deviations more heavily than smaller ones.

A more efficient computational formula

Expanding the definition above gives an equivalent formula that's usually much quicker to calculate with, especially by hand:

$\text{Variance} = \dfrac{\displaystyle\sum x^2}{n} - \bar{x}^2.$
Where this comes from

Expanding $(x-\bar x)^2 = x^2 - 2\bar x x + \bar x^2$ and summing over all $n$ values gives $\sum x^2 - 2\bar x \sum x + n\bar x^2$. Since $\sum x = n\bar x$, this simplifies to $\sum x^2 - 2n\bar x^2 + n\bar x^2 = \sum x^2 - n\bar x^2$, and dividing by $n$ gives the formula above. You only need to find $\sum x$ and $\sum x^2$ once — no need to calculate every individual deviation from the mean.

Standard deviation

The standard deviation is the square root of the variance:

$\text{Standard deviation} = \sqrt{\text{Variance}}.$

Taking the square root brings the measure back into the same units as the original data (variance is in squared units, which usually isn't meaningful on its own), which is why standard deviation — not variance — is normally quoted when describing a dataset's spread.

Grouped and frequency data

When data is given in a frequency table, each value $x$ is weighted by its frequency $f$, and $n = \sum f$:

$\text{Variance} = \dfrac{\displaystyle\sum f(x-\bar x)^2}{\sum f} = \dfrac{\displaystyle\sum fx^2}{\sum f} - \bar x^2.$

For grouped continuous data, $x$ is replaced by the midpoint of each class, exactly as when estimating the mean — so the result is only ever an estimate of the true variance and standard deviation.

Worked example 1

Variance and SD from raw data
Find the variance and standard deviation of $2, 4, 6, 8, 10$.
MethodFind $\bar x$, then $\sum x^2$
1
$\sum x = 30$, so $\bar x = 30/5=6$.
Mean of the five values.
2
$\sum x^2 = 4+16+36+64+100=220$.
Sum of the squares of each value.
3
Variance $=\dfrac{220}{5}-6^2=44-36=8$.
Computational formula.
4
Standard deviation $=\sqrt{8}\approx 2.83$.
Square root of the variance.
▪ solved
Check using the definition

Deviations from the mean are $-4,-2,0,2,4$; squaring gives $16,4,0,4,16$, which sum to $40$. Dividing by $n=5$ gives variance $=8$ — the same answer, confirming both formulas agree.

Worked example 2

Variance and SD from a frequency table
The table shows the number of pets owned by 20 students. Find the mean, variance and standard deviation.
Pets, $x$1234
Frequency, $f$5942
MethodBuild $\sum fx$ and $\sum fx^2$
1
$\sum f = 20$, $\sum fx = 1(5)+2(9)+3(4)+4(2)=5+18+12+8=43$.
Total frequency and weighted sum.
2
$\bar x = 43/20=2.15$.
Mean from the frequency table.
3
$\sum fx^2 = 1^2(5)+2^2(9)+3^2(4)+4^2(2)=5+36+36+32=109$.
Weight each squared value by its frequency.
4
Variance $=\dfrac{109}{20}-2.15^2=5.45-4.6225=0.8275$.
Computational formula.
5
Standard deviation $=\sqrt{0.8275}\approx 0.910$.
Square root of the variance.
▪ solved

Worked example 3

Estimating variance and SD from grouped data
The ages of 40 people at a conference are grouped below. Estimate the mean and standard deviation.
Age (years)0–910–1920–2930–39
Midpoint, $x$4.514.524.534.5
Frequency, $f$815125
MethodUse midpoints in place of $x$
1
$\sum f=40$, $\sum fx = 8(4.5)+15(14.5)+12(24.5)+5(34.5)=36+217.5+294+172.5=720$.
Weighted sum of midpoints.
2
$\bar x = 720/40=18$.
Estimated mean.
3
$\sum fx^2 = 8(4.5)^2+15(14.5)^2+12(24.5)^2+5(34.5)^2=162+3153.75+7203+5951.25=16470$.
Weighted sum of squared midpoints.
4
Variance $\approx \dfrac{16470}{40}-18^2=411.75-324=87.75$.
Computational formula, using midpoints.
5
Standard deviation $\approx\sqrt{87.75}\approx 9.37$ years.
Square root of the estimated variance.
▪ solved
Remember

Because every value in a class is replaced by the class midpoint, this is only an estimate — the true ages within each class aren't actually all equal to the midpoint.

Worked example 4

Comparing spread using standard deviation · Challenge
Two machines fill bottles with juice. For a sample of 50 bottles from each machine, $n=50$, $\sum x=605$ for both, but $\sum x^2 = 7350.5$ for Machine A and $\sum x^2=7328$ for Machine B (in ml). Compare the consistency of the two machines.
MethodFind both standard deviations and compare
1
Both machines: $\bar x = 605/50=12.1$ ml.
Same mean fill volume for both.
2
Machine A: variance $=\dfrac{7350.5}{50}-12.1^2=147.01-146.41=0.6$, so SD $=\sqrt{0.6}\approx 0.775$ ml.
Computational formula for Machine A.
3
Machine B: variance $=\dfrac{7328}{50}-12.1^2=146.56-146.41=0.15$, so SD $=\sqrt{0.15}\approx 0.387$ ml.
Same formula for Machine B.
4
Both machines fill bottles to the same mean volume, but Machine B has a smaller standard deviation, so it fills bottles more consistently.
Smaller SD means less variation about the mean.
▪ solved
Look deeper

This is exactly why standard deviation matters in practice: two datasets can have identical means and still behave very differently. A quality-control team would prefer Machine B even though, on average, the two machines look the same.

Common mistake

Don't forget to square root at the end — the computational formula $\sum x^2/n - \bar x^2$ gives the variance, not the standard deviation. It's easy to compute the variance correctly and then write it down as if it were the SD.

Check yourself

A dataset of 10 values has $\sum x = 150$ and $\sum x^2 = 2360$. Find the variance and standard deviation.
(Hint: find $\bar x$ first, then use the computational formula.)

Method
1
$\bar x = 150/10=15$.
2
Variance $=\dfrac{2360}{10}-15^2=236-225=11$.
3
Standard deviation $=\sqrt{11}\approx 3.32$.
▪ solved