Skip to content

Variance and standard deviation, explained

5 min read

Short answer

Variance measures spread by averaging each value's squared gap to the mean: Var⁡(X)=E[(X−μ)2]=E[X2]−μ2\operatorname{Var}(X)=E[(X-\mu)^2]=E[X^2]-\mu^2. The standard deviation σ=Var⁡(X)\sigma=\sqrt{\operatorname{Var}(X)} is its square root, in the same units as the data, and tells you a typical distance from the mean.

Data values on a number line with arrows showing each deviation from the mean of 50246810mean = 5+4−3variance = average of (deviation)² = 4
Eight values with mean 5: the arrows show each deviation. Squaring and averaging them gives the variance, 4.

Why square the deviations

Deviations x−μx-\mu cancel out (they always sum to zero), so you cannot just average them. Squaring makes every term positive and punishes big deviations more. Taking the square root at the end brings the units back to those of the data.

Population vs sample

If you have the whole population, divide the sum of squared deviations by nn. If you have only a sample and want to estimate the population variance, divide by n−1n-1 (Bessel's correction), because deviations from the sample mean are slightly too small on average.

Worked example

Find the variance and standard deviation of the data 2,4,4,4,5,5,7,92,4,4,4,5,5,7,9 (treat it as a whole population).

Mean μ=408=5\mu=\tfrac{40}{8}=5. Squared deviations: 9,1,1,1,0,0,4,169,1,1,1,0,0,4,16, summing to 3232. σ2=328=4,σ=2.\sigma^2=\frac{32}{8}=4,\qquad \sigma=2. If this were a sample, s2=327≈4.57s^2=\tfrac{32}{7}\approx4.57 and s≈2.14s\approx2.14.

For a fair die, E[X]=3.5E[X]=3.5 and E[X2]=916E[X^2]=\tfrac{91}6, so Var⁡=916−3.52=3512≈2.92\operatorname{Var}=\tfrac{91}{6}-3.5^2=\tfrac{35}{12}\approx2.92.

Try it yourself

Find the population and the sample variance of 1,3,51,3,5.

Show the answer

Mean 3; squared deviations 4,0,44,0,4 sum to 8. Population variance =83≈2.67=\tfrac83\approx2.67; sample variance =82=4=\tfrac82=4.

Keep going with practice

Variance and standard deviation are covered in Vidi's Linear Algebra & Probability course with graded practice.