Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

How to Find the Variance of a Random Variable

Variance measures how far a random variable typically lands from its mean, in squared units. The quickest route is the shortcut: the mean of the square minus the square of the mean.

Recognize the task

The question asks for spread, risk, variability, Var⁡(X)\operatorname{Var}(X) or σ2\sigma^2. Typical inputs: a pmf table, a density on an interval, a linear change aX+baX + b of a variable with known variance. Test: do you know (or can you compute) E[X]E[X]? Then you are one more weighted sum away from the variance.
Variance is defined in the variance lesson.

Two ways to do it

Shortcut formulausual
Var⁡(X)=E[X2]−(E[X])2\operatorname{Var}(X) = E[X^2] - (E[X])^2
Two weighted sums and one subtraction (computational formula). Best for tables and densities.
Definition with deviationsby definition
Var⁡(X)=E[(X−μ)2]\operatorname{Var}(X) = E\big[(X - \mu)^2\big]
Square each distance from the mean and average (definition of variance). Good when the mean is a round number.

Steps

StepOn X∈{0,1,2,3}X \in \{0, 1, 2, 3\} with probabilities 0.1, 0.3, 0.4, 0.20.1,\ 0.3,\ 0.4,\ 0.2
1Find the mean. Compute μ=E[X]\mu = E[X] as on the expected value page.μ=1.7\mu = 1.7
2Find the mean of the square. Square each value, keep the same probabilities, and add. For a density, integrate x2f(x)x^2 f(x).E[X2]=0+0.3+1.6+1.8=3.7E[X^2] = 0 + 0.3 + 1.6 + 1.8 = 3.7
3Subtract the square of the mean. Use the shortcut formula.Var⁡(X)=3.7−1.72=3.7−2.89=0.81\operatorname{Var}(X) = 3.7 - 1.7^2 = 3.7 - 2.89 = 0.81
4Check the sign. A variance is never negative. A negative result means an arithmetic slip, usually in E[X2]E[X^2].0.81≥00.81 \geq 0 ✓

Worked examples

Example 1 · a fair die

shortcut
E[X]=3.5E[X] = 3.5, E[X2]=1+4+9+16+25+366=916E[X^2] = \frac{1 + 4 + 9 + 16 + 25 + 36}{6} = \frac{91}{6}
two weighted sums
Var⁡(X)=916−494=182−14712\operatorname{Var}(X) = \frac{91}{6} - \frac{49}{4} = \frac{182 - 147}{12}
common denominator 12
Var⁡(X)=3512\operatorname{Var}(X) = \frac{35}{12}
about 2.91672.9167

Example 2 · a linear change of variable

$aX + b$
Var⁡(X)=4\operatorname{Var}(X) = 4, find Var⁡(3X+2)\operatorname{Var}(3X + 2)
Var⁡(3X+2)=32Var⁡(X)\operatorname{Var}(3X + 2) = 3^2 \operatorname{Var}(X)
shift drops out, scale squares
=9⋅4=36= 9 \cdot 4 = 36
multiply

Example 3 · a density on an interval

continuous
f(x)=2xf(x) = 2x on [0,1][0, 1], E[X]=23E[X] = \frac{2}{3}
mean from before
E[X2]=∫01x2⋅2x dx=12E[X^2] = \int_0^1 x^2 \cdot 2x \, dx = \frac{1}{2}
integrate x2f(x)x^2 f(x)
Var⁡(X)=12−49=118\operatorname{Var}(X) = \frac{1}{2} - \frac{4}{9} = \frac{1}{18}
shortcut formula
See how the spread changes with the shape of the distribution in the variance visualizer.

See it happen

Variance is the average squared distance from the balance point. Values far from the mean count much more than values close to it, because the distance is squared. The shortcut works because expanding (X−μ)2(X - \mu)^2 and averaging gives E[X2]−2μ2+μ2E[X^2] - 2\mu^2 + \mu^2, which is E[X2]−μ2E[X^2] - \mu^2.

Common mistakes

Subtracting the mean instead of its square

✗ Var⁡(X)=E[X2]−E[X]=3.7−1.7=2\operatorname{Var}(X) = E[X^2] - E[X] = 3.7 - 1.7 = 2
✓ Var⁡(X)=3.7−1.72=0.81\operatorname{Var}(X) = 3.7 - 1.7^2 = 0.81

Keeping the shift and not squaring the scale

✗ Var⁡(3X+2)=3⋅4+2=14\operatorname{Var}(3X + 2) = 3 \cdot 4 + 2 = 14
✓ Var⁡(3X+2)=9⋅4=36\operatorname{Var}(3X + 2) = 9 \cdot 4 = 36
The linear transform rule is Var⁡(aX+b)=a2Var⁡(X)\operatorname{Var}(aX + b) = a^2 \operatorname{Var}(X).

Subtracting variances for a difference

✗ Var⁡(X−Y)=4−9=−5\operatorname{Var}(X - Y) = 4 - 9 = -5 for independent X,YX, Y
✓ Var⁡(X−Y)=4+9=13\operatorname{Var}(X - Y) = 4 + 9 = 13: spreads always add