Hexa Scholar

Expectation as a balance point, variance as spread

Put each value of a random variable on a number line and give it its probability as a weight. Where does the line balance, and how do you measure how spread out the weight is?

The balance point summarizes where the distribution is located. The variance summarizes how spread out it is around that point. You will find the first by eye, then see how the second responds when the weights move.

Before you start · 3 quick checks on reading a PMF, weighted averages and balancing a seesaw, about 3 min
Setup

A random variable and its PMF. A discrete random variable \(X\) takes values \(x_1, x_2, \dots\) with probabilities \(p(x) = P(X = x)\), each at least 0 and together adding to 1. The lesson on PMF, PDF and CDF drew these as bars; the lesson on conditional probability and the Monty Hall problem worked with the events behind them. Unless stated otherwise, the random variables in the activities on this page take only finitely many values.

Probabilities as weights. Picture a rod with no weight of its own lying along the number line. At each value \(x\) of \(X\) stands a mass equal to \(p(x)\), so the masses add up to 1. A fulcrum, a support under the rod, sits at a point \(c\). A mass \(p(x)\) at signed distance \(x - c\) from the fulcrum turns the rod with moment \(p(x)(x - c)\): positive to the right of \(c\), negative to the left, and larger the farther out the mass is. The rod balances where the moments of all the masses cancel.

Fine print: what the picture leaves out

A real rod tipped off balance keeps turning until something stops it. The figures on this page draw the tilt in proportion to the total moment instead, so that a small miss shows as a small tilt. The strength of gravity and the physical size of the weights play no part: only probabilities and positions matter.

1 See

Find the balance point

Choose a layout, move the fulcrum to where you think the rod balances, then check your guess.

How to move the fulcrum, and what happens after a check

Drag the triangle under the rod, or focus it and use the arrow keys (steps of 0.05), Page Up and Page Down (steps of 1), Home (0) and End (10). Check my balance point then shows the balance point, tilts the rod by the amount you were off, and says what your choice coincided with.

After a check you can keep moving the fulcrum: the verdict stays with your checked guess, and the line under it follows the current fulcrum. Press Guess again or choose another layout to start a new guess.

2 Try

Spreading and shifting the masses

Definitions

Expectation. For a discrete \(X\), \(E[X] = \sum x\,p(x)\), the balance point from stage 1. For a function \(g\), the random variable \(g(X)\) has expectation

\[E[g(X)] = \sum g(x)\,p(x).\]

Variance. Write \(\mu = E[X]\). The variance is the probability-weighted average of the squared distances from \(\mu\),

\[\begin{aligned} \operatorname{Var}(X) &= E[(X - \mu)^2] \\ &= \sum (x - \mu)^2 p(x). \end{aligned}\]

Standard deviation. \(\operatorname{SD}(X) = \sqrt{\operatorname{Var}(X)}\). If \(X\) is measured in dollars, \(E[X]\) and \(\operatorname{SD}(X)\) are in dollars and \(\operatorname{Var}(X)\) is in squared dollars.

Fine print: densities, and expectations that do not exist

For a continuous \(X\) with density \(f\), the sums become integrals: \(E[X] = \int x f(x)\,dx\) and \(\operatorname{Var}(X) = \int (x - \mu)^2 f(x)\,dx\). For the uniform density \(\tfrac{1}{2}\) on \([1, 3]\) from the previous lesson, \(E[X] = \int_1^3 \tfrac{x}{2}\,dx = 2\), the middle of the interval.

The integral gives a finite expectation only when \(\int \lvert x \rvert f(x)\,dx\) is finite. That can fail when the density has a heavy tail. For \(f(x) = 1/x^2\) on \(x \ge 1\) (and 0 below 1), the integral of \(x f(x) = 1/x\) from 1 to \(t\) is \(\ln t\), which grows without bound, so this \(X\) has no finite expectation, and no variance either. Sums over infinitely many values can fail in the same way.

3 Prove

The shortcut formula for the variance

Theorem

Assumptions. \(X\) is a random variable with finitely many values, each with positive probability, and \(\mu = E[X]\). The proof uses three facts about expectations of such variables:

  • for a function \(g\), \(E[g(X)] = \sum g(x)\,p(x)\);
  • linearity: for numbers \(a\), \(b\), \(d\) and random variables \(Y\), \(Z\) on the same experiment, \(E[aY + bZ + d] = aE[Y] + bE[Z] + d\), with no independence needed;
  • a probability-weighted average of numbers that are all at least 0 is at least 0.

Conclusion.

\[\operatorname{Var}(X) = E[X^2] - (E[X])^2.\]

In particular \(E[X^2] \ge (E[X])^2\), with equality exactly when \(X\) is a constant.

What else follows
  • The same algebra proves the rule for linear changes from stage 2. The mean of \(aX + b\) is \(a\mu + b\), so its deviation is \(aX + b - (a\mu + b) = a(X - \mu)\). Squaring gives \(a^2 (X - \mu)^2\), and linearity gives \(\operatorname{Var}(aX + b) = a^2 \operatorname{Var}(X)\).
  • The theorem holds for a continuous \(X\) whenever \(E[X^2]\) is finite, with the same proof and integrals in place of sums.
  • \(E[g(X)]\) and \(g(E[X])\) can differ. For \(g(x) = x^2\) the theorem says how far apart they are: \(E[X^2] - (E[X])^2 = \operatorname{Var}(X)\). For a linear \(g(x) = ax + b\) they are equal, by linearity.
4 Apply

Problems

Each problem has hints and a full solution.

More problems
Key point An expectation is a probability-weighted average: a fair price for a game, a mean return, an expected loss. The variance measures spread around it, often most easily as \(E[X^2] - (E[X])^2\), and it changes by \(a^2\) under a change of units \(aX + b\); report the standard deviation, which is in the units of \(X\).
Level Intro Prerequisites reading a PMF, weighted averages and moments on a seesaw (refreshed in Before you start), and the lesson on PMF, PDF and CDF Time ~40 min

Next in Probability: From binomial to Poisson: the law of rare events (in preparation).

Further reading