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:
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:
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$:
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$
1
2
3
4
Frequency, $f$
5
9
4
2
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$.
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.)