Lesson 4 of 8 · 18 min

Variance and standard deviation

Measure the spread of a discrete random variable with the variance and standard deviation, by the definition and by the quicker computational form, and use them to compare distributions.

What you will be able to do

  • Calculate Var⁡(X)=∑pi(xi−μ)2\Var(X) = \sum p_i (x_i - \mu)^2 from a probability function.
  • Use the computational form Var⁡(X)=E⁡(X2)−μ2\Var(X) = \E(X^2) - \mu^2.
  • Calculate the standard deviation σ=Var⁡(X)\sigma = \sqrt{\Var(X)} and interpret it as a typical distance from the mean.
  • Compare the spread of two distributions with the same mean.

Two random variables can have the same mean and still behave very differently. Let XX take the values 1, 2, 3 with probabilities 0.25, 0.5, 0.25, and let YY take the values 0, 2, 4 with the same probabilities. Both have mean 2, but YY lands further from 2. A mean on its own doesn't tell you how risky or predictable something is. For that you need a measure of spread.

Same mean, different spread: XX (orange) and YY (blue). Both balance at 2.

Key idea

Variance and standard deviation

The variance of XX is the probability-weighted mean of the squared distances from the mean:

Var⁡(X)=∑pi(xi−μ)2.\Var(X) = \sum p_i (x_i - \mu)^2.

The standard deviation is its square root,

σ=Var⁡(X),\sigma = \sqrt{\Var(X)},

which is back in the units of XX. Roughly, σ\sigma is a typical distance between XX and its mean.

For XX above: the distances from the mean are −1-1, 0 and 1, so

Var⁡(X)=0.25(−1)2+0.5(0)2+0.25(1)2=0.5,σX=0.5≈0.71.\Var(X) = 0.25(-1)^2 + 0.5(0)^2 + 0.25(1)^2 = 0.5, \quad \sigma_X = \sqrt{0.5} \approx 0.71.

For YY the distances are −2-2, 0 and 2, so Var⁡(Y)=0.25(4)+0+0.25(4)=2\Var(Y) = 0.25(4) + 0 + 0.25(4) = 2 and σY=2≈1.41\sigma_Y = \sqrt{2} \approx 1.41. YY is twice as spread out as XX.

Let XX be the number of heads when three fair coins are tossed, so P(X=0)=18P(X = 0) = \frac{1}{8}, P(X=1)=38P(X = 1) = \frac{3}{8}, P(X=2)=38P(X = 2) = \frac{3}{8}, P(X=3)=18P(X = 3) = \frac{1}{8} and E⁡(X)=1.5\E(X) = 1.5. Find Var⁡(X)\Var(X).

Reads asYour answer shows here as maths.

The definition needs μ\mu first and then a subtraction for every value. Expanding the square gives a quicker route that only needs ∑pixi2\sum p_i x_i^2.

Computational form of the variance
Var⁡(X)=E⁡(X2)−μ2,where E⁡(X2)=∑pixi2\Var(X) = \E(X^2) - \mu^2, \qquad \text{where } \E(X^2) = \sum p_i x_i^2
Why the two forms agree

Expand (xi−μ)2=xi2−2μxi+μ2(x_i - \mu)^2 = x_i^2 - 2\mu x_i + \mu^2 and split the sum:

∑pi(xi−μ)2=∑pixi2−2μ∑pixi+μ2∑pi.\sum p_i (x_i - \mu)^2 = \sum p_i x_i^2 - 2\mu \sum p_i x_i + \mu^2 \sum p_i.

Now ∑pixi=μ\sum p_i x_i = \mu and ∑pi=1\sum p_i = 1, so this is

E⁡(X2)−2μ⋅μ+μ2=E⁡(X2)−μ2.\E(X^2) - 2\mu \cdot \mu + \mu^2 = \E(X^2) - \mu^2.

Worked example

Calculate the variance and standard deviation

  • Simple familiar

For the number of goals in a quarter from the earlier example,

xx01234
P(X=x)P(X = x)0.10.30.350.150.1

with E⁡(X)=1.85\E(X) = 1.85, calculate Var⁡(X)\Var(X) and the standard deviation of XX, correct to 2 decimal places.

4 steps

Try it yourself first, then check the working one step at a time.

Method

  1. Find μ=E⁡(X)\mu = \E(X).

  2. Find E⁡(X2)=∑pixi2\E(X^2) = \sum p_i x_i^2.

  3. Var⁡(X)=E⁡(X2)−μ2\Var(X) = \E(X^2) - \mu^2; then σ=Var⁡(X)\sigma = \sqrt{\Var(X)}.

Watch out for

  • Using (E⁡(X))2(\E(X))^2 in place of E⁡(X2)\E(X^2), giving 0.

  • Rounding μ\mu before squaring it.

  • Stopping at the variance when the standard deviation is asked for.

Interactive

Mean and spread together

The bracket marks μ±σ\mu \pm \sigma, one standard deviation either side of the mean. Which values of XX lie inside it?

For the score XX on a fair die, E⁡(X)=72\E(X) = \frac{7}{2}. Use Var⁡(X)=E⁡(X2)−μ2\Var(X) = \E(X^2) - \mu^2 to find Var⁡(X)\Var(X).

Reads asYour answer shows here as maths.

Common mistake

E⁡(X2)\E(X^2) is not (E⁡(X))2(\E(X))^2

E⁡(X2)\E(X^2) squares each value, then takes the weighted average. (E⁡(X))2(\E(X))^2 takes the average, then squares. Their difference is the variance, so they are equal only when there is no spread at all. Since a variance can't be negative, E⁡(X2)≥μ2\E(X^2) \ge \mu^2 always: a negative variance means an arithmetic slip.

Without technology

Set out a table with rows xx, P(X=x)P(X = x), x P(X=x)x\,P(X = x) and x2P(X=x)x^2 P(X = x). Add the last two rows to get μ\mu and E⁡(X2)\E(X^2), then Var⁡(X)=E⁡(X2)−μ2\Var(X) = \E(X^2) - \mu^2. Keep fractions exact on Paper 1.

With technology

Enter the values in one list and the probabilities in another, then run one-variable statistics with the probability list as the frequency list. The calculator's mean is μ\mu and its σx\sigma_x is the standard deviation. Ignore sxs_x, which is for samples.

Extension: scaling and shifting change the spread differently

Adding a constant moves every value, and the mean, by the same amount, so the distances from the mean don't change. Multiplying by aa multiplies every distance by aa, and every squared distance by a2a^2:

Var⁡(aX+b)=a2Var⁡(X),sd(aX+b)=∣a∣ σ.\Var(aX + b) = a^2 \Var(X), \qquad \text{sd}(aX + b) = |a|\,\sigma.

If the drink stall's sales XX have σ=3\sigma = 3, its profit 4X−204X - 20 has standard deviation 4×3=$124 \times 3 = \$12.

Exam tip

Variance or standard deviation?

Read which one is asked for. The variance is in squared units (dollars squared, people squared), so when you interpret spread in context, use the standard deviation. Give it to the accuracy asked, rounding only at the end.

Summary

  • Var⁡(X)=∑pi(xi−μ)2\Var(X) = \sum p_i (x_i - \mu)^2 measures spread in squared units.

  • The quicker form is Var⁡(X)=E⁡(X2)−μ2\Var(X) = \E(X^2) - \mu^2 with E⁡(X2)=∑pixi2\E(X^2) = \sum p_i x_i^2.

  • σ=Var⁡(X)\sigma = \sqrt{\Var(X)} is in the units of XX: a typical distance from the mean.

  • Distributions with the same mean can have very different spreads.

  • A variance is never negative, and E⁡(X2)≠(E⁡(X))2\E(X^2) \neq (\E(X))^2 unless there is no spread.

Finished the lesson?

Try the 2 quick checks above and the lesson completes itself, or mark it complete now.

Lesson 4 of 80% read

Save your progress with a free account