Skip to content

Variance and standard deviation

Spread is the average squared distance from the mean, drawn as squares; its square root, the standard deviation, is in the units of the data.

Helps to know firstExpected value

Helps to know first
This topic

First, the picture

Mark a die’s six faces on a line. From each face, draw a square out to the mean. Watch what their average square is.

Spread, drawn as squares

A fair die's faces, each with chance 1/6: squares out to the mean, and their average.

A fair die's six faces on a line, each with chance 1/6, and their mean, 3.5.

mean
3.50
variance
–
standard deviation
–
0.00 / 9.00 s
Describe this picture

A number line from 1 to 6 with a dot at each face of a fair die and the mean, 3.5, marked by a triangle. In the clip a square grows from each dot out to the mean, standing on the line, its side the distance from the dot to the mean, each lightly shaded for the face’s probability, 16\tfrac16. The caption gives their areas, 6.25, 2.25 and 0.25, twice each. Then the six squares are averaged into one square, drawn beside them in a second colour and labelled with its area, 2.9167, and its side, 1.7078; readouts give the mean, the variance (the average square) and the standard deviation (its side). After the clip a question asks: move one dot twice as far from the mean, and its square becomes twice as big, four times as big, or the same? A tap picks an answer. Then each dot has a handle: drag one along the line, or focus it and use the arrow keys, and its square, the mean, the average square and the readouts follow.

Spread as squares

Two dice can have the same mean and still feel different. A fair die gives 1 to 6, centred on 3.5. A die marked 3, 3, 4, 4, 3, 4 also averages 3.5, but its rolls never stray far. The mean tells you where the values sit; it says nothing about how far they wander.

To measure the wandering, start with each value’s distance from the mean, its deviation x−μXx-\mu_X. For the fair die the deviations are −2.5,−1.5,−0.5,0.5,1.5,2.5-2.5,-1.5,-0.5,0.5,1.5,2.5. Their average is 0: the mean sits in the middle, so the minus side cancels the plus side. Averaging plain deviations always gives 0.

So square them first, as the picture did. A square is never negative, and it grows fast with distance. The squares are 6.25,2.25,0.256.25,2.25,0.25, each twice, and their average is

2×(6.25+2.25+0.25)6=17.56=3512=2.9167.\frac{2\times(6.25+2.25+0.25)}{6}=\frac{17.5}{6}=\frac{35}{12}=2.9167.

That average square is the variance:

Var{X}=E{(X−μX)2}=∑x(x−μX)2 pX(x).\mathrm{Var}\{X\}=\mathbb{E}\{(X-\mu_X)^2\}=\sum_x(x-\mu_X)^2\,p_X(x).

The variance is in squared units: for a die, “faces squared”. To get back to the units of XX, take the square root. That is the standard deviation, σX=Var{X}\sigma_X=\sqrt{\mathrm{Var}\{X\}}, the side of the average square in the picture. For the die, σX=35/12=1.7078\sigma_X=\sqrt{35/12}=1.7078.

I write the variance σX2\sigma_X^2 too. In the statistics pages a σ\sigma is a standard deviation; signal processing pages use a bare σ\sigma for the decay rate of the Laplace variable.

After the clip, you answered the question about moving a dot. Now drag one dot twice as far from the mean and watch its square: it becomes four times as big. Twice the distance makes four times the square, which is why the variance listens most to the values far from the mean.

Watch out

The standard deviation measures distance from the mean, not how bumpy the bars look. Take a variable that is 1 or 6, each with chance 12\tfrac12: two tall bars. Its standard deviation is 2.5, larger than the fair die’s 1.708, because every value sits 2.5 from the mean.

A shortcut

Expand the square inside the mean and use linearity from Expected value:

E{(X−μX)2}=E{X2}−2μX E{X}+μX2=E{X2}−μX2.\begin{aligned} \mathbb{E}\{(X-\mu_X)^2\}&=\mathbb{E}\{X^2\}-2\mu_X\,\mathbb{E}\{X\}+\mu_X^2\\ &=\mathbb{E}\{X^2\}-\mu_X^2. \end{aligned}

The variance is the mean of the square minus the square of the mean: exactly the gap between E{X2}\mathbb{E}\{X^2\} and E{X}2\mathbb{E}\{X\}^2 that the last page found. For the die, 91/6−12.25=35/1291/6-12.25=35/12, the same as before.

Changing units

Shift every value by bb and the mean shifts too, so every deviation stays the same: the spread does not change. Multiply every value by aa and every deviation is multiplied by aa, so every square is multiplied by a2a^2:

Var{aX+b}=a2 Var{X},σaX+b=∣a∣ σX.\mathrm{Var}\{aX+b\}=a^2\,\mathrm{Var}\{X\},\qquad \sigma_{aX+b}=\lvert a\rvert\,\sigma_X.

So if Var{X}=4\mathrm{Var}\{X\}=4, then Var{3X+2}=9×4=36\mathrm{Var}\{3X+2\}=9\times4=36.

Spread of the named shapes

Bernoulli. For a variable that is 1 with chance pp and 0 otherwise, X2=XX^2=X, so E{X2}=p\mathbb{E}\{X^2\}=p and

Var{X}=p−p2=p(1−p).\mathrm{Var}\{X\}=p-p^2=p(1-p).

It is largest at p=12p=\tfrac12, a fair coin, where it is 0.250.25.

Binomial. A binomial count is a sum of nn independent Bernoulli variables. For independent variables the variances add, as Sums of random variables shows, so

Var{X}=np(1−p).\mathrm{Var}\{X\}=np(1-p).

The ten-row board of Discrete random variables at p=12p=\tfrac12 has variance 10×0.25=2.510\times0.25=2.5 and standard deviation 1.58111.5811.

This also explains the typical miss of What probability measures. The share of nn darts inside a shape is X/nX/n, with XX binomial. By the scaling rule its variance is np(1−p)/n2=p(1−p)/nnp(1-p)/n^2=p(1-p)/n, and its standard deviation is the typical miss, p(1−p)/n\sqrt{p(1-p)/n}.

Beyond spread

The mean and the variance describe a centre and a width. Two more words describe a shape. Skewness measures lopsidedness: a long tail on one side, like incomes, where a few values sit far above the rest. Kurtosis measures heavy tails: how often values land very far from the mean compared with a bell, as with large market crashes.

Worked example

1. The die, both ways. By the definition: deviations ±2.5,±1.5,±0.5\pm2.5,\pm1.5,\pm0.5, squares 6.25,2.25,0.256.25,2.25,0.25 twice each, mean 17.5/6=2.916717.5/6=2.9167. By the shortcut: 91/6−3.52=15.1667−12.25=2.916791/6-3.5^2=15.1667-12.25=2.9167. Standard deviation 1.70781.7078.

2. A biased coin. A Bernoulli variable with p=0.3p=0.3 has variance 0.3×0.7=0.210.3\times0.7=0.21 and standard deviation 0.21=0.4583\sqrt{0.21}=0.4583.

3. Units. Daily temperatures in a city have a standard deviation of 5 °C. In degrees Fahrenheit, F=1.8 C+32F=1.8\,C+32. The +32+32 moves the mean only; the 1.81.8 stretches the spread, so the standard deviation is 1.8×5=91.8\times5=9 °F.

Try it yourself. A fair coin scored 0 or 1 has variance 12×12=0.25\tfrac12\times\tfrac12=0.25.

Where you’ll meet this

Noise power. Remove a signal’s mean and its average power is its variance. The noise in a sensor or a radio is quoted by its standard deviation, often called its RMS value, as in Random variables for signals in the signal processing course.

Measurement error. A scale whose readings have a standard deviation of 0.2 g scatters about 0.2 g around the true weight on a typical reading. Instruments are sold by this number.

Tolerances. A part machined to 10 mm with a standard deviation of 0.01 mm fits; one with 0.1 mm may not. Factories track the standard deviation of their parts as closely as the mean.

Risk. In finance the standard deviation of a return is a common first measure of risk: two investments with the same mean return can carry very different spreads.

Where this leads · squared length

Take nn values xkx_k and their plain average xˉ\bar x, and write the differences xk−xˉx_k-\bar x as one vector. The sum ∑k(xk−xˉ)2\sum_k(x_k-\bar x)^2 is that vector’s squared length, its dot product with itself. Two such vectors meet at an angle whose cosine is the correlation of Covariance and correlation.

Reference card

QuantityFormulaNotes
VarianceVar{X}=E{(X−μX)2}\mathrm{Var}\{X\}=\mathbb{E}\{(X-\mu_X)^2\}average squared deviation, σX2\sigma_X^2
ShortcutVar{X}=E{X2}−μX2\mathrm{Var}\{X\}=\mathbb{E}\{X^2\}-\mu_X^2mean of the square minus square of the mean
Standard deviationσX=Var{X}\sigma_X=\sqrt{\mathrm{Var}\{X\}}in the units of XX
UnitsVar{aX+b}=a2Var{X}\mathrm{Var}\{aX+b\}=a^2\mathrm{Var}\{X\}shifts do not change spread
Bernoullip(1−p)p(1-p)0.25 for a fair coin
Binomial Bin(n,p)\mathrm{Bin}(n,p)np(1−p)np(1-p)2.5 for ten fair pegs
Fair die35/12=2.916735/12=2.9167, SD 1.70781.7078
Shapeskewness: lopsided; kurtosis: heavy tailswords only here

Keep reading with a free account.

By creating an account you accept the terms of use.

Sign in

Already have an account? Use the service you signed up with.

Or keep reading: get new lessons by email

Are you 13 or over?

Accounts and email updates are for people aged 13 or over. We keep only your answer, never your date of birth.

End of the lesson

Where to go next.

Phasorium

Account

Sign inKeep your place on any device

Subjects

Site

Look