On this page
The law of total expectation is how to take an average in pieces: split a hard problem into easy cases, average each case, then weight the cases by their probabilities. It also goes by the law of iterated expectations, Adam's law, the tower rule and the smoothing property, as the Wikipedia entry on the law of total expectation lists. It turns JEE-style "expected number of tries" questions into a few lines of algebra.
What is the law of total expectation?
For random variables X and Y on the same probability space, with E[X] defined, E[X] = E[E[X | Y]] (law of total expectation, Wikipedia).
E[X | Y] is "the average of X once you know Y", and it depends on Y, so it is itself random. The outer E averages those conditional averages.
When the cases are events A1, A2, ... that split the sample space with no overlap, the same law reads E[X] = Σ E[X | Ai] P(Ai) (Wikipedia).
You have used this without the name. Say Section A has 40 students averaging 62 marks and Section B has 20 students averaging 71. A student picked at random is from Section A with probability 2/3, so the overall average is (2/3)(62) + (1/3)(71) = 65. That is an average of averages, weighted by how likely each case is, and not (62 + 71)/2 = 66.5.
If conditional probability itself feels shaky, look it up in the Fermi Concept Library, which covers every concept in physics, chemistry, biology, mathematics and computing, each with its own lesson.
How do you split a problem by cases?
The real skill is choosing what to condition on. Three choices come up again and again:
The first step: what happens on the first toss or roll. Best when the process can restart.
A hidden count: how many items or trials there are. Best for random sums.
A category: which section or bag something came from. Best for mixtures.
The first-step choice works because a failure sends you back to the beginning, so the expected remaining wait is the same unknown E you are solving for. For the simplest case, waiting for one head with a fair coin, E = (1/2)(1) + (1/2)(1 + E), so E = 2. We go through that one fully in why the expected wait for the first head is 2.
How many tosses until two heads in a row?
Let E be the expected number of fair-coin tosses until you first see HH. Condition on how the tosses begin. These three cases cover every possibility:
T first (probability 1/2): 1 toss used, back to the start, so 1 + E.
HT first (probability 1/4): 2 tosses used, back to the start, so 2 + E.
HH first (probability 1/4): done in 2.
The law of total expectation gives E = (1/2)(1 + E) + (1/4)(2 + E) + (1/4)(2).
Multiply out: E = 1/2 + E/2 + 1/2 + E/4 + 1/2 = 3/2 + (3/4)E. So E/4 = 3/2, and E = 6.
A common slip is to answer 4 because HH has probability 1/4. That treats tosses as separate pairs and misses that a T after an H wipes out your progress. Our post on expected tosses to get two heads in a row checks the 6 another way. If you keep setting up the cases wrongly, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer.
What is the expected value of a random sum?
Roll a fair die to get a number N, then toss N fair coins. How many heads do you expect?
The number of coins is itself random, so condition on it. If N = n, the expected number of heads is n/2. So E[heads | N] = N/2, and the tower rule gives E[heads] = E[N/2] = E[N]/2 = 3.5/2 = 1.75.
The same argument gives a general rule. If X1, X2, ... are independent and identically distributed, and N is a whole-number random variable independent of them, with N and the X's having finite expectations, then E[X1 + ... + XN] = E[N] E[X1]. This is Wald's equation, named after the mathematician Abraham Wald (Wald's equation, Wikipedia). Conditioning on N turns it into an ordinary sum, and linearity does the rest; see how linearity of expectation works with indicator variables.
How should you practise the tower rule?
A short plan across four sittings:
Redo the class-average and first-head examples without notes.
Derive E = 6 for HH from a blank page. Then try waiting for HT; it comes out to 4, and explaining why it is smaller is a good test of how restarts work.
Do random sums: die-then-coins, then a random number of customers each spending a random amount.
Work mixed problems from your probability chapter, writing "condition on ___" before any algebra.
For a longer treatment, MIT OpenCourseWare has a free university course, 6.041SC Probabilistic Systems Analysis and Applied Probability.
Next time an expectation question looks stuck, ask one thing first: what, if I knew it, would make this easy?


