The differences from the mean
Take the three values 2, 4 and 6. Their mean is x̄ = (2 + 4 + 6) ÷ 3 = 12 ÷ 3 = 4. The differences from the mean, x − x̄, are 2 − 4 = −2, 4 − 4 = 0 and 6 − 4 = +2.
The bar for 2 ends 2 below the mean line at 4, the bar for 4 ends on it, and the bar for 6 ends 2 above it.
Square them so they cannot cancel
Added as they are, the differences cancel: −2 + 0 + 2 = 0. They always do, because the mean is the balance point of the values.
Square each difference first: , and . A square is never negative, so the squares cannot cancel. Their total, 4 + 0 + 4 = 8, could be 0 only if every value were equal to the mean.
The squared differences of 2, 4 and 6 from the mean: 4, 0 and 4. None of them is below 0.
Average the squares, then take the square root
Average the squares: . That is the variance. Then take its square root: . That is the standard deviation. The square root undoes the squaring and brings the answer back to the units of the data.
In symbols, . Laid out as a table, there is one row for each value, a column for x − x̄ and a column for , and the total of the last column is divided by n.
The squared differences total 8, so the variance is and . The last column, the squares of the values themselves, is used next.
A shorter formula
The definition needs the mean before any square can be worked out, and when the mean is not a whole number every difference is a decimal. Expanding the square gives a formula that avoids this.
Each squared difference expands like any bracket: . Add this up over all n values. The terms give . The middle terms give , and since , that is . The last term, , is added n times, which gives . So .
Dividing by n gives the variance as , the mean of the squares minus the square of the mean. So .
Check it on 2, 4 and 6. The squares of the values are 4, 16 and 36, so . Then , the same variance as before, and .
When the mean is not a whole number
A team scores 1, 2, 4 and 7 goals in four matches. The mean is 14 ÷ 4 = 3.5 goals. By the definition, the differences from 3.5 are −2.5, −1.5, 0.5 and 3.5, and their squares are 6.25, 2.25, 0.25 and 12.25, which total 21. The variance is 21 ÷ 4 = 5.25.
By the shorter formula, the squares of the values are 1, 4, 16 and 49, whole numbers that total 70. Then , the same variance. Either way, goals.
The two methods always agree. The definition shows what the standard deviation measures; the shorter formula is usually quicker by hand, because it works with the values themselves until the last step.
By the definition, 21 ÷ 4 = 5.25. By the shorter formula, . The variance is the same.
Mistakes with the shorter formula
is the sum of the squares, not the square of the sum. For 1, 2, 4 and 7, , while the square of the sum is .
Divide by n first, and then subtract the square of the mean: 70 ÷ 4 − 12.25, not (70 − 12.25) ÷ 4.
Use the exact mean. The two numbers being subtracted are often close together, so a rounded mean can change the answer a great deal. Rounding the mean 3.5 up to 4 gives 17.5 − 16 = 1.5 in place of 5.25.
Worked example: Two Bottle-Filling Machines with the Same Mean Weight and Different Standard Deviations
Question Two machines fill bottles that should hold 500 g. Five bottles are weighed from each machine. Machine A gave 497, 499, 500, 501 and 503 g. Machine B gave 494, 498, 500, 502 and 506 g. (a) Show that the two machines have the same mean weight, and find the standard deviation of each set of five bottles, dividing by the number of bottles. (b) A bottle is rejected when its weight differs from 500 g by more than 5 g. How many of the ten bottles are rejected, and which machine should be serviced?
1.Find each mean. Machine A: 497 + 499 + 500 + 501 + 503 = 2500, and 2500 ÷ 5 = 500 g. Machine B: 494 + 498 + 500 + 502 + 506 = 2500, and 2500 ÷ 5 = 500 g. Both machines average the target weight exactly.
Both machines total 2500 g over 5 bottles, so both means are 500 g. 2.Machine A, distance from the mean and its square: −3 gives 9, −1 gives 1, 0 gives 0, 1 gives 1 and 3 gives 9. The squares total 9 + 1 + 0 + 1 + 9 = 20, so the variance is 20 ÷ 5 = 4 and the standard deviation is √4 = 2 g.
Machine A, squared distances from 500 g: 9 + 1 + 0 + 1 + 9 = 20, so the variance is 4 and the standard deviation is √4 = 2 g. 3.Machine B, the same two columns: −6 gives 36, −2 gives 4, 0 gives 0, 2 gives 4 and 6 gives 36. The squares total 36 + 4 + 0 + 4 + 36 = 80, so the variance is 80 ÷ 5 = 16 and the standard deviation is √16 = 4 g.
Machine B: 36 + 4 + 0 + 4 + 36 = 80, so the variance is 16 and the standard deviation is √16 = 4 g. 4.(a) Both means are 500 g. Machine A has a standard deviation of 2 g and machine B one of 4 g, so machine B's weights sit twice as far from the target on average.
(a) The means are equal at 500 g, and the standard deviations are 2 g and 4 g. 5.(b) A bottle is kept when it weighs between 495 g and 505 g. Machine A's lightest bottle is 497 g and its heaviest is 503 g, so all five are kept. Machine B's 494 g and 506 g bottles are outside the limits, so 2 bottles are rejected, both from machine B, and machine B is the machine to service. Check: every rejected bottle is more than one standard deviation of machine B from the target, and machine A's whole range, 497 g to 503 g, sits inside the limits.
(b) A bottle is kept between 495 g and 505 g. Machine A keeps all five; machine B loses 494 g and 506 g, so 2 bottles are rejected and machine B is the one to service.
Answer: (a) both machines have a mean of 500 g, and the standard deviations are 2 g for machine A and 4 g for machine B; (b) 2 bottles are rejected, both from machine B, so machine B should be serviced
Common mistakes
- Adding the distances from the mean without squaring them. For machine A those distances are −3, −1, 0, 1 and 3, which add to 0, and the same happens for every data set: the distances below the mean cancel the distances above it exactly. Squaring is what stops the cancellation.
- Forgetting the square root and calling 16 the standard deviation of machine B. The squares are in square grams, so 16 is the variance. The standard deviation is √16 = 4 g, and only that can be compared with a tolerance measured in grams.