Module 1 of 3 · Lesson 1 of 4
Random Variables, Expectation and Variance
What you will be able to do
The learner can compute the expectation and variance of a discrete random variable by either route, and apply the linearity and scaling rules to a linear transformation of it.
Orientation
What expectation and variance each report
Two numbers summarise a distribution, and they answer different questions.
A random variable is a function, not a variable.
Expectation is a weighted average. For a fair die,
a number no face shows. Expectation is where the distribution balances, not a prediction of any single roll. The first thing to unlearn about the name.
Variance measures spread. For the same die,
Both behave predictably under a linear transformation, and differently from each other. Adding a constant moves the mean and leaves the variance untouched. Multiplying by
What this unit does not settle is what happens when two random variables are combined.
Definition
Reading the definitions: why each rule takes the form it does
Why variance squares the deviations. The average deviation
The cost is units. Squared pips are not pips, which is why
Why the two variance formulas agree. Expanding
Why
Why
Intuition
Balance points and moment arms
Place the probabilities as weights along a number line. Two pictures follow, and most of what is counterintuitive about expectation and variance dissolves in them.
Expectation is where the line balances. For a fair die the weights are equal and the balance point sits midway between 1 and 6, at 3.5, which is why no face shows it. A balance point need not coincide with any weight, and nothing requires it to be attainable. This is also why the expectation of a count can be 1.8 children per household: the balance point of a distribution over integers is rarely an integer.
Variance is the weighted average of squared distances from that point. Squaring is what stops the deviations cancelling, since the balance point is exactly where they sum to zero. It also means distant values count disproportionately: a value twice as far contributes four times as much. That is why a single extreme outcome can dominate a variance while barely moving a mean, and why a variance is sensitive to the tail of a distribution in a way an average is not.
The transformation rules read straight off the picture. Sliding every weight along the line by
Where the picture stops. It holds one variable. The moment two variables are combined, the question becomes whether their deviations reinforce or cancel, which no single number line can show. That is the subject of the unit on covariance.
Example
A die, and a linear transformation
One distribution, worked completely, then put through the rules.
---
1. A fair die.
Expectation.
Variance, both ways. First by the definition, averaging squared deviations from 3.5:
Then by the shortcut, with
Both give
Note the deviations themselves sum to zero:
---
2. A linear transformation. Let
By the rules:
Verified directly by computing over
The
---
3. Where this is heading. The same two rules applied to an average,
Procedure
Computing an expectation and a variance
To compute an expectation.
Step 1 — List the values and their probabilities, and check they sum to 1. A mass function failing this is misread or mis-specified, and everything downstream inherits the error.
Step 2 — Multiply and add:
Step 3 — For a transformed variable, prefer the rules.
To compute a variance.
Step 4 — Use
Step 5 — Sanity-check the result. Variance is never negative; if it comes out so, the subtraction was done in the wrong order or
Step 6 — For transformations, square the multiplier and ignore the shift:
Where it goes wrong.
- Treating
as a typical value. A fair die averages 3.5 and shows no 3.5. - Forgetting the square in
, givinginstead of . - Adding
to the variance. A shift cannot change a spread. - Applying
, which fails for every non-linear. - Stopping at
without subtracting . - Reporting a variance where a standard deviation was wanted, leaving the answer in squared units.
Warning
Interpreting an expected value
An expected value is a probability-weighted average of the values a random variable takes. It is not a prediction of any single outcome and need not be a value the variable can take.
A fair die has
Other cases behave the same way. A variable taking
Expectation does not determine spread. These two distributions share
| Distribution | Values | |
|---|---|---|
| Fair die | ||
| Two values |
The variances differ by a factor of about
Expectation is a property of the distribution, not of a sample.
This distinction also separates two different quantities.
The difference is
Consequences: the average of squares is at least as large as the square of the average, with equality exactly when
In reporting, "the long-run average is