← 🔗 Joint Distributions, Covariance & Conditional Expectation
Subtopic 3 of 3

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

  1. Compute E[X | Y = y] for each value y of the first stage.
  2. E[X] = Σ P(Y = y) E[X | Y = y].
  3. First-step analysis: condition on what happens in the first step.
  4. If the process restarts after a failure, write E in terms of itself and solve.
  5. 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/2P(N = n) · E[heads | N = n]
11/60.50.0833
21/610.1667
31/61.50.25
41/620.3333
51/62.50.4167
61/630.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?

Remember: E[X] = Σ P(Y = y) E[X | Y = y]; condition on the first step and use the restart.
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.