5.3Conditional expectation and the law of total expectation
The idea
Conditional expectation E[X | Y = y] is the average of X once you know Y. The law of total expectation averages those conditional averages.
Think of it like this: The average marks of a class equal the average of the section averages, weighted by section size.
Why it exists
It solves "two-stage" averages and the restart trick (first-step analysis) in one line.
How it works
- Compute E[X | Y = y] for each value y of the first stage.
- E[X] = Σ P(Y = y) E[X | Y = y].
- First-step analysis: condition on what happens in the first step.
- If the process restarts after a failure, write E in terms of itself and solve.
- For the geometric distribution: E = p·1 + (1 − p)(1 + E) gives E = 1/p.
Worked example: A die is rolled, then that many coins are flipped; expected heads
E[heads | N = n] = n/2, so E = Σ (1/6)(n/2) = 3.5/2 = 1.75. The first tab of the lab shows every row.
Now play with it
- →Open the second tab and move p: the formula gives E = 1/p.
- →Compare with the table in the first tab: what does the last row add up to?
| N (die) | P(N = n) | E[heads | N = n] = n/2 | P(N = n) · E[heads | N = n] |
|---|---|---|---|
| 1 | 1/6 | 0.5 | 0.0833 |
| 2 | 1/6 | 1 | 0.1667 |
| 3 | 1/6 | 1.5 | 0.25 |
| 4 | 1/6 | 2 | 0.3333 |
| 5 | 1/6 | 2.5 | 0.4167 |
| 6 | 1/6 | 3 | 0.5 |
| E[heads] = Σ P(N = n) · E[heads | N = n] | 1.75 | ||
Law of total expectation: E[X] = E[ E[X | N] ]. Here E[N] = 3.5, each coin contributes 1/2, so E[heads] = 3.5 / 2 = 1.75 without any table.
Check yourself
A fair die is rolled, then a fair coin is flipped that many times. What is the expected number of heads?
Exam notes (the dense version)
E[X | Y = y] is the average of X among outcomes with Y = y. Law of total expectation: E[X] = Σ P(Y = y) E[X | Y = y]. It powers first-step analysis: condition on what happens first and use the fact that the process restarts (geometric mean 1/p).
Previous year questions: Joint Distributions, Covariance & Conditional Expectation (2)
PYQs are grouped by topic, so this is the full set for Joint Distributions, Covariance & Conditional Expectation; try the ones that match this subtopic. Open all 2 on the topic page.