Probability and statistics ยท Part 4 of 5
Expectation and variance
Learn to compute the expectation and variance of a random variable, interpret them, and transform them under scaling and shifts.
Probability and statistics9 min read
A random variable can take many values, so a full distribution table is often more detail than we need. Sometimes we just want one number that says what to expect 'on average': if a game costs $2 to play and pays out unpredictably, is it worth playing? Expectation answers that.
But an average alone can mislead. Two investments can both average a 5% return, while one barely wobbles and the other swings wildly. Variance is the standard second number: it measures how far outcomes typically sit from the mean. Together, expectation and variance compress a distribution into a useful two-number summary.
Expectation: the long-run average
The expectation (or expected value) of a discrete random variable is the weighted average of its possible values, where each value is weighted by its probability:
The word 'expectation' does not mean the outcome you expect to see once. A die never lands on 3.5, yet . The right picture is the long-run average: if you repeat the experiment many times and average the results, the average settles toward . This is why expectation is the natural tool for decisions repeated over time, like pricing insurance or evaluating a game strategy.
Example 1. Expected value of a die roll A fair six-sided die shows , each with probability . Find .
Multiply each outcome by its probability and add:
No single roll gives 3.5, but the average of many rolls approaches it.
Variance: spread around the mean
Variance measures how far typically is from its mean. It is defined as the average squared distance from the mean:
The second form is usually easier for computation: find the average of , then subtract the square of the average. The units are squared (dollars, cm), so for interpretation we often take the square root, called the standard deviation , which is back in the original units.
Why square the distances? Squaring makes all deviations positive so they cannot cancel out, and it penalizes large deviations heavily, which is usually what we care about when we talk about risk.
Example 2. Variance of a small bet A game pays with probability and with probability . Find and .
First the mean:
Then the average of the squares:
Now the shortcut formula:
Check by the definition: . Both routes agree. The standard deviation is .
How expectation and variance transform
If you rescale a random variable, its summary statistics rescale in simple, predictable ways. For constants and :
Adding shifts every outcome by the same amount, so the average shifts by but the spread does not change at all. Multiplying by stretches distances by , and since variance measures squared distances, it picks up a factor . These rules let you convert units (say, Celsius to Fahrenheit) without recomputing everything from the distribution.
Example 3. Converting a temperature distribution A temperature in Celsius, , has and . Let be the temperature in Fahrenheit. Find and .
Apply the linearity rule for expectation:
Apply the scaling rule for variance; the contributes nothing:
The standard deviation scales by : .
A complete worked example
Putting it all together: read the distribution, compute , compute , then subtract. Always confirm the probabilities sum to 1 before you start, and sanity-check that the mean lies inside the range of values.
Example 4. Full computation from a distribution table A random variable has , , . Find and .
Check the probabilities sum to 1: . Good.
Compute the mean:
Compute the mean of the squares:
Subtract the squared mean:
Check with the definition: . The standard deviation is .
Example 5. Is the game worth playing? A raffle ticket costs $2. With probability you win a $15 prize; otherwise you win nothing. Let be your net profit per ticket. Find and interpret it.
Net profit is if you win, and if you lose:
On average you lose 50 cents per ticket. For the spread, compute :
The variance is large relative to the mean, so individual outcomes (winning or losing ) differ a lot from the average loss of .
Common mistakes
- Computing as ; these are different, and the gap between them is exactly the variance.
- Forgetting the term contributes nothing to variance, writing ; the correct rule is .
- Averaging the outcomes without weights, e.g. when the probabilities are ; the correct mean is .
- Reporting variance in the original units; variance is in squared units, so take for the standard deviation.
- Using probabilities that do not sum to 1, which makes every downstream statistic meaningless; always verify first.
Practice
- A random variable takes values and , each with probability . Find .
- A random variable takes values with probabilities respectively. Find .
- A fair six-sided die is rolled and the result is . Find the standard deviation of , i.e. . Give the exact value as a square root.
- A random variable has and . Let . Find .
- A lottery ticket costs $5. With probability it pays a $100 prize; otherwise it pays nothing. Let be the net profit from buying one ticket (prize minus cost). Find .
Answers
- .
- and , so .
- and , so the standard deviation is .
- Only the multiplier matters for spread: .
- Net profit is with probability and with probability , so .
With expectation and variance in hand, the next lesson on estimation and regression shows how to use sample data to estimate these quantities and model relationships between variables.