ProbabilityLesson 4 of 6
The average, and the swing
Expectation, variance, and standard deviation
The average before it happens
Section titled “The average before it happens”Take every value a random quantity X can land on, multiply each value by its probability, and add. That’s the expectation — the average, computed before anything happens:
Decoding: is “the expectation of X”. means “add these up”, one term per possible value. Each term is a value times , the probability that X lands exactly on . Every value × its chance, summed.
Picture the distribution as weights on the number line: is its balance point.
A coin scored Heads = 1, Tails = 0: .
The coin can never show 1/2. The expectation needn’t be a possible outcome — it’s the long-run average per flip: flip a thousand times, divide the total score by a thousand, and you’ll hover near 1/2.
A four-sided die D, faces 1 through 4, each with probability 1/4. We can write the sum as a table with a totals row — one row per value, and the expectation is the sum of the last column:
| value | probability | contribution: value × probability |
|---|---|---|
| 1 | 1/4 | 1/4 |
| 2 | 1/4 | 2/4 |
| 3 | 1/4 | 3/4 |
| 4 | 1/4 | 4/4 |
| sum | 1 | 10/4 = 5/2 |
For a continuous quantity, swap for (an integral): . Slice the number line into slivers of width . Each sliver holds a small probability — , density × width. Each sliver contributes value × its sliver of probability — and contributions left of zero count negative. Add them all up.
Uniform on [−1, 1] — every point between −1 and 1 equally likely — has density 1/2. Its average is 0 by symmetry: every value has an equally likely negative twin, so the slivers left of 0 exactly cancel the slivers right of 0.
The swing
Section titled “The swing”The expectation is the center. Variance is the average squared miss from that center:
Read it inside out: is the miss. Why square? Because raw misses average to exactly zero — is what “balance point” means — so their average can’t tell a tight spread from a wild one. Squaring makes every miss count, big ones hardest; the outer averages them. For the die, whose center is 5/2, that’s the same kind of table — miss, square it, weight it, total:
| value | miss: value − 5/2 | squared miss | × probability 1/4 |
|---|---|---|---|
| 1 | −3/2 | 9/4 | 9/16 |
| 2 | −1/2 | 1/4 | 1/16 |
| 3 | +1/2 | 1/4 | 1/16 |
| 4 | +3/2 | 9/4 | 9/16 |
| sum | 20/16 = 5/4 |
All four faces have equal probability, but faces 1 and 4 contribute nine times as much to the variance as faces 2 and 3: their distance from the mean is three times larger, and .
For finite variance, expanding the square gives a useful shortcut: — the average of the square minus the square of the average. No misses to compute:
- Die: , so — same answer as the table.
- Coin: , so .
- Uniform on [−1, 1]: — the area under from −1 to 1 works out to 2/3 — so .
The standard deviation is — is the square root, which undoes the squaring, so the answer is back in the same units as X. That’s the swing’s size on X’s own scale.
Rules for sums
Section titled “Rules for sums”These are rules for expectation and variance. The quantities below have finite means and variances.
Linearity: the expectation of a sum is the sum of the expectations, even when the variables depend on each other. For three fair coin scores, . This also holds if all three scores record the same flip: then their sum is either 0 or 3, each with probability , so its expectation is still .
When the pieces are independent — one’s outcome tells you nothing about the other’s — variances add too.
- Three coins: .
- Die + coin: and .
- It even mixes kinds. Coin + uniform on [−1, 1]: and .
Linearity of expectation needs no independence. For variance, the full rule is . Independence makes covariance zero; zero covariance is already sufficient, even without independence. We will define covariance in two at once.
Go deeper: where the shortcut comes from
Write for — it’s just a number. Expand the square: . Take the expectation term by term (that’s linearity), letting the constant slide out: . The shortcut follows from expanding the square and applying linearity.
Try the moves
Section titled “Try the moves”A probability is an expectation in disguise
Section titled “A probability is an expectation in disguise”Write for the indicator — a flag that reads 1 when X = 2 and 0 otherwise (the braces hold the condition being flagged). Its expectation follows by considering its two possible values:
The average of a flag is the fraction of the time the flag is up — so any probability can be rewritten as an expectation. Accuracy on a random example can therefore be written as the expectation of a correct-answer indicator. For other loss functions, expected loss is the probability-weighted average of the per-example loss; the loss itself need not be a probability. When a paper writes — the reads “drawn from” — it is asking for exactly this page’s move: the weighted average of whatever sits in the brackets, weights given by p.
Center and spread: two numbers per distribution. Next, four distributions so common they have names.