Lesson 5 of 8 · 16 min

Variance and standard deviation

Measure the spread of a continuous random variable with Var⁡(X)\Var(X) and σ\sigma, using the definition or the quicker form E⁡(X2)−μ2\E(X^2) - \mu^2, and interpret the result.

What you will be able to do

  • Calculate Var⁡(X)=∫−∞∞(x−μ)2 p(x) dx\Var(X) = \int_{-\infty}^{\infty} (x - \mu)^2\,p(x)\,dx and σ=Var⁡(X)\sigma = \sqrt{\Var(X)}.
  • Use the computational form Var⁡(X)=E⁡(X2)−μ2\Var(X) = \E(X^2) - \mu^2, and explain why it is equivalent.
  • Use the uniform variance (b−a)212\frac{(b - a)^2}{12}.
  • Compare the spread of two distributions from their graphs and standard deviations.

Two densities can have the same mean and still behave very differently. Both densities below live on [0,4][0, 4] and balance at x=2x = 2, but the hump keeps values close to 2 while the flat one spreads them evenly to the ends. The mean cannot tell them apart. You need a measure of spread.

Same mean, different spread. The uniform density p(x)=14p(x) = \frac{1}{4} (blue) has σ≈1.15\sigma \approx 1.15; the hump p(x)=332x(4−x)p(x) = \frac{3}{32}x(4 - x) (orange) has σ≈0.89\sigma \approx 0.89.

Definition

Variance and standard deviation

The variance of XX is the expected squared distance from the mean:

Var⁡(X)=σ2=∫−∞∞(x−μ)2 p(x) dx.\Var(X) = \sigma^2 = \int_{-\infty}^{\infty} (x - \mu)^2\,p(x)\,dx.

The standard deviation is σ=Var⁡(X)\sigma = \sqrt{\Var(X)}, in the same units as XX. Both are always ≥0\ge 0, and larger values mean more spread.

Expanding (x−μ)2(x - \mu)^2 gives a form that is almost always quicker by hand, because you integrate x2p(x)x^2 p(x) and never have to expand a bracket with μ\mu in it.

Computational form
Var⁡(X)=E⁡(X2)−μ2,where E⁡(X2)=∫−∞∞x2 p(x) dx\Var(X) = \E(X^2) - \mu^2, \qquad \text{where } \E(X^2) = \int_{-\infty}^{\infty} x^2\,p(x)\,dx
Why the two forms agree

Expand the square and split the integral:

∫(x−μ)2p(x) dx=∫x2p(x) dx−2μ∫x p(x) dx+μ2∫p(x) dx.\int (x - \mu)^2 p(x)\,dx = \int x^2 p(x)\,dx - 2\mu \int x\,p(x)\,dx + \mu^2 \int p(x)\,dx.

The three integrals are E⁡(X2)\E(X^2), μ\mu and 11, so

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

Worked example

Variance and standard deviation of p(x)=38x2p(x) = \frac{3}{8}x^2

  • Complex familiar
  • Technology free

XX has pdf p(x)=38x2p(x) = \frac{3}{8}x^2 for 0≤x≤20 \le x \le 2, and 0 elsewhere, with E⁡(X)=32\E(X) = \frac{3}{2}.

Find Var⁡(X)\Var(X) exactly, and the standard deviation correct to 3 decimal places.

4 steps

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

Method

  1. E⁡(X2)=∫x2p(x) dx\E(X^2) = \int x^2 p(x)\,dx.

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

Watch out for

  • Using μ\mu instead of μ2\mu^2: 125−32\frac{12}{5} - \frac{3}{2} is not the variance.

For p(x)=x8p(x) = \frac{x}{8} on 0≤x≤40 \le x \le 4, you found E⁡(X)=83\E(X) = \frac{8}{3}. Given E⁡(X2)=8\E(X^2) = 8, find Var⁡(X)\Var(X).

Reads asYour answer shows here as maths.
Interactive

Squeeze the spread

A blend of the flat and hump densities. The mean stays at 2 for every aa, but as aa grows the area gathers near 2 and σ\sigma shrinks, from about 1.15 at a=0a = 0 to about 0.89 at a=1a = 1.

Key idea

Uniform distribution

For XX uniform on [a,b][a, b],

E⁡(X)=a+b2,Var⁡(X)=(b−a)212,σ=b−a12.\E(X) = \frac{a + b}{2}, \qquad \Var(X) = \frac{(b - a)^2}{12}, \qquad \sigma = \frac{b - a}{\sqrt{12}}.
Deriving the uniform variance

Write w=b−aw = b - a. Shifting a distribution does not change its spread, so take XX uniform on [0,w][0, w], where μ=w2\mu = \frac{w}{2} and p(x)=1wp(x) = \frac{1}{w}:

E⁡(X2)=∫0wx2w dx=w23,Var⁡(X)=w23−w24=w212.\E(X^2) = \int_0^w \frac{x^2}{w}\,dx = \frac{w^2}{3}, \qquad \Var(X) = \frac{w^2}{3} - \frac{w^2}{4} = \frac{w^2}{12}.

Buses arrive every 12 minutes and your waiting time WW is uniform on [0,12][0, 12]. Find the standard deviation of WW, in minutes, correct to 2 decimal places.

in min

Round to 2 decimal places.

Worked example

Spread of p(x)=k(1−x2)p(x) = k(1 - x^2) on [−1,1][-1, 1]

  • Complex familiar

The error XX mm in the position of a drilled hole is modelled by p(x)=k(1−x2)p(x) = k(1 - x^2) for −1≤x≤1-1 \le x \le 1, and 0 elsewhere.

(a) Find kk.

(b) Write down E⁡(X)\E(X), giving a reason.

(c) Find the standard deviation of XX, correct to 3 decimal places.

(d) Find the probability that XX is within one standard deviation of the mean, correct to 3 decimal places.

5 steps

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

Method

  1. Find kk from total area 1.

  2. Use symmetry for the mean where you can.

  3. Var⁡(X)=E⁡(X2)−μ2\Var(X) = \E(X^2) - \mu^2; when μ=0\mu = 0 this is just E⁡(X2)\E(X^2).

Watch out for

  • Losing the negative limit: [x−x33]−11\left[x - \frac{x^3}{3}\right]_{-1}^{1} is 23−(−23)\frac{2}{3} - \left(-\frac{2}{3}\right).

Common mistake

E(X²) is not (E(X))²

E⁡(X2)=∫x2p(x) dx\E(X^2) = \int x^2 p(x)\,dx squares each value before averaging. μ2\mu^2 squares the average. Mixing them up gives Var⁡(X)=0\Var(X) = 0 or a negative number, which is impossible: a variance is never negative.

Exam tip

Technology on Paper 2

On Paper 2 your calculator can evaluate these definite integrals. Still write the integral you are evaluating, with its limits, for example Var⁡(X)=∫02(x−1.5)2⋅38x2 dx\Var(X) = \int_0^2 (x - 1.5)^2 \cdot \frac{3}{8}x^2\,dx. On Paper 1 the integrands will be polynomials or other functions you can antidifferentiate by hand.

Summary

  • Var⁡(X)=∫(x−μ)2p(x) dx\Var(X) = \int (x - \mu)^2 p(x)\,dx measures spread; σ=Var⁡(X)\sigma = \sqrt{\Var(X)} is in the units of XX.

  • Quicker by hand: Var⁡(X)=E⁡(X2)−μ2\Var(X) = \E(X^2) - \mu^2 with E⁡(X2)=∫x2p(x) dx\E(X^2) = \int x^2 p(x)\,dx.

  • Uniform on [a,b][a, b]: Var⁡(X)=(b−a)212\Var(X) = \frac{(b - a)^2}{12}.

  • A density with more area far from the mean has a larger standard deviation.

  • A variance is never negative; if yours is, recheck E⁡(X2)\E(X^2) and μ2\mu^2.

Finished the lesson?

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

Lesson 5 of 80% read

Save your progress with a free account