St · Statistics & Probability

Law of Iterated Expectations: A Worked Example

Updated 13 October 2026

At a glance

  1. 1. Choose a condition

    Identify the random variable or information you will condition on.

  2. 2. Find conditional means

    Calculate the expected value of the outcome separately for each condition.

  3. 3. Weight the means

    Average those conditional means using the probabilities of the conditions.

  4. 4. Check directly

    When possible, compute the unconditional expectation from the outcome probabilities and compare.

The law of iterated expectations lets you find an overall mean by first calculating conditional means and then averaging them. It is also called the tower property. The key is to weight each conditional mean by how likely its condition is.

The law in symbols

If XX is an integrable random variable and YY is another random variable, then

E[E[X∣Y]]=E[X].\mathbb{E}[\mathbb{E}[X\mid Y]] = \mathbb{E}[X].

The inner conditional expectation, E[X∣Y]\mathbb{E}[X\mid Y], is itself a random variable: its value depends on the value of YY. The outer expectation averages that random variable over the possible values of YY.

For a discrete variable YY, this becomes

E[X]=∑yE[X∣Y=y]P(Y=y),\mathbb{E}[X] = \sum_y \mathbb{E}[X\mid Y=y]P(Y=y),

where the sum runs over the possible values of YY. This is a weighted average of conditional means. For continuous variables, the sum is replaced by an integral over the distribution of YY.

Worked example: choosing a bag

Suppose you choose one of two bags. Bag A is chosen with probability 2/32/3, and bag B with probability 1/31/3. You then draw one number from the chosen bag:

  • Bag A contains 0 and 6, each with probability 1/21/2.
  • Bag B contains 3 and 9, each with probability 1/21/2.

Let YY be the bag chosen and let XX be the number drawn. First compute the mean within each bag:

E[X∣Y=A]=0+62=3,E[X∣Y=B]=3+92=6.\begin{aligned} \mathbb{E}[X\mid Y=A] &= \frac{0+6}{2}=3,\\ \mathbb{E}[X\mid Y=B] &= \frac{3+9}{2}=6. \end{aligned}

Now average those means, weighting by the probabilities of choosing each bag:

E[X]=E[X∣Y=A]P(Y=A)+E[X∣Y=B]P(Y=B)=3(23)+6(13)=4.\begin{aligned} \mathbb{E}[X] &= \mathbb{E}[X\mid Y=A]P(Y=A) + \mathbb{E}[X\mid Y=B]P(Y=B)\\ &= 3\left(\frac{2}{3}\right)+6\left(\frac{1}{3}\right)\\ &= 4. \end{aligned}

You can verify the result by finding the overall probabilities of the four possible draws. The outcomes 0 and 6 each have probability (2/3)(1/2)=1/3(2/3)(1/2)=1/3. The outcomes 3 and 9 each have probability (1/3)(1/2)=1/6(1/3)(1/2)=1/6. Thus

E[X]=0(13)+6(13)+3(16)+9(16)=4.\mathbb{E}[X] = 0\left(\frac{1}{3}\right)+6\left(\frac{1}{3}\right)+3\left(\frac{1}{6}\right)+9\left(\frac{1}{6}\right)=4.

Both calculations give the same overall mean. The first groups the calculation by bag; the second groups it by the number drawn.

Why the rule works

If YY has finitely many possible values, those values split all outcomes into separate cases. In each case, calculate the average of XX under that condition. The overall average is then the sum of those case averages, each multiplied by the probability of its case. This is the same weighted-average principle used to combine group means.

For a continuous YY, the same idea applies across its range. In density notation, when the relevant densities and expectations exist,

E[X]=∫E[X∣Y=y]fY(y) dy,\mathbb{E}[X] = \int \mathbb{E}[X\mid Y=y] f_Y(y)\,dy,

where fYf_Y is the probability density of YY. More generally, the theorem is stated using conditional expectation given the information generated by YY; it does not require YY to be discrete or continuous.

Common mistakes

Taking an unweighted average. In the bag example, averaging 3 and 6 gives 4.5, which is wrong because the bags are not equally likely. Use the probabilities of the conditions as weights.

Treating the conditional mean as a fixed number. The notation E[X∣Y]\mathbb{E}[X\mid Y] represents a random variable that changes with YY. By contrast, E[X∣Y=y]\mathbb{E}[X\mid Y=y] is the conditional mean for one specified value yy.

Assuming independence. The law does not say that XX and YY are independent. It holds whether or not they are related. If they are independent, then E[X∣Y]=E[X]\mathbb{E}[X\mid Y]=\mathbb{E}[X] (under the usual conditions), so the identity becomes immediate.

Moving nonlinear functions through an expectation. In general, E[g(X)∣Y]\mathbb{E}[g(X)\mid Y] is not equal to g(E[X∣Y])g(\mathbb{E}[X\mid Y]). The tower property applies by taking the expectation of a conditional expectation; it does not make expectation commute with arbitrary functions.

When this is useful

Use the law when a problem naturally separates into groups, stages, or scenarios. For example, you might first condition on a customer type, a weather state, or the number of trials, calculate the expected outcome within each case, and then average over the cases. It is also a standard step in probability proofs and in calculations involving conditional models.

The same principle works with more information: if you condition first on one information set and then on a coarser one, the conditional expectations can be averaged in stages. This is why the identity is known as the tower property.

References

  1. Probability and Statistics, Morris H. DeGroot and Mark J. Schervish
  2. A First Course in Probability, Sheldon Ross

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.