Random variables and expectation
Compute the expected value and variance of a random variable as weighted averages.
Builds on: Probability and distributions, Reading formulas: indices and sums
What the animation says
A game of chance
Here is a game. One play pays zero, two, or ten euros. Zero comes up half the time, two thirty percent, ten twenty percent. One play tells you almost nothing. You might win ten, you might win zero. So we judge it over many plays: the average per play, and how far single plays swing around it. Quick guess: across many plays, what do you earn per play on average?
Weighted average
It's two euros sixty. Picture a hundred plays. Fifty pay zero, thirty pay two, twenty pay ten. That's zero plus sixty plus two hundred: two hundred sixty euros over a hundred plays, so two sixty per play. Each value counts in proportion to its chance. That's the expected value, a weighted average. It needn't be a possible payout. A fair die averages three and a half. Now measure each payout's distance from two sixty, with its sign. What's the weighted average of those distances?
Square, then weight
Zero. Minus two sixty, minus point six, plus seven point four: weighted, they cancel exactly. So we square the distances first. Six seventy-six, point three six, fifty-four seventy-six. Then weight them by their chances, not a plain average, and add. Three thirty-eight, plus point one oh eight, plus ten point nine five two: fourteen point four four. That's the variance. Tap the payout that supplies most of that spread.
Shortcut and standard deviation
The ten: far from the mean, so its squared distance dominates. About seventy-six percent. A shortcut gives the same variance: weight the squared payouts, giving twenty-one point two. Then subtract the mean squared, six seventy-six. Fourteen point four four again. Careful: weighting the squares is not the same as squaring the mean. Variance is in euros squared. Its square root, three point eight euros, is the standard deviation: the typical swing around the mean.
Weighted average, and spread around it
The two formulas
Worked: payouts 0, 2, 10
Remember
On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.
Bytewise
All courses