Tutorials › VEE Mathematical Statistics › Deriving the Law of Iterated Expectation

VEE Mathematical Statistics · Conditional Distributions and Expectations · Tutorial 296 of 880

Deriving the Law of Iterated Expectation

Learn to justify and apply the law of iterated expectation using conditional probability tables or densities, while checking the conditions required for a finite expectation.

Intermediate 10 min read

What You'll Learn

  • State the integrability condition for the law of iterated expectation.
  • Derive the identity by expanding discrete conditional averages as sums.
  • Derive the identity for continuous variables using joint and conditional densities.
  • Compute an unconditional mean by averaging conditional means.
  • Verify an iterated-expectation calculation directly from a joint distribution.
  • Recognize when an expectation is undefined and the identity cannot be used as a finite-mean formula.

Why Average a Conditional Average?

A conditional expectation gives the average value of a random variable after information about another random variable is known. The law of iterated expectation says that if those conditional averages are then averaged over the distribution of the conditioning variable, the result is the original unconditional mean. The identity is simple to state, but its justification depends on how the conditional average is formed and on whether the relevant expectations exist.

For example, an insurer might estimate average claim payment separately for several hypothetical risk classes. Averaging those class-specific means using the proportions of policies in each class must reproduce the overall mean payment. The same principle applies when the conditioning variable is continuous, but the weighted sum becomes an integral.

Definition: Let \(X\) be an integrable random variable and let \(Y\) be another random variable. The law of iterated expectation is $$ E\!\left[E[X\mid Y]\right]=E[X]. $$ Here, \(E[X\mid Y]\) is a random variable determined by \(Y\): it is the conditional mean of \(X\) given the observed value of \(Y\). The required integrability condition for this finite-mean identity is \(E[|X|]<\infty\).

The notation \(E[X\mid Y=y]\) denotes a number, when the conditional distribution at \(Y=y\) is defined. The notation \(E[X\mid Y]\) denotes the random variable obtained by evaluating that conditional-mean function at the random value \(Y\). For values \(y\) having probability zero, the conditional mean may be assigned arbitrarily without changing \(E[X\mid Y]\) as a random variable.

Derivation for Discrete Random Variables

Suppose \(X\) and \(Y\) have a joint probability mass function \(p_{X,Y}(x,y)=P(X=x,Y=y)\), and suppose \(E[|X|]<\infty\). For any \(y\) with \(P(Y=y)>0\), the conditional probability mass function is

$$ P(X=x\mid Y=y)=\frac{p_{X,Y}(x,y)}{P(Y=y)}. $$

The conditional mean is found by summing \(x\) times this conditional probability. Averaging that conditional mean over the possible values of \(Y\) gives the result:

$$ \begin{aligned} E\!\left[E[X\mid Y]\right] &=\sum_y E[X\mid Y=y]P(Y=y)\\ &=\sum_y\left(\sum_x xP(X=x\mid Y=y)\right)P(Y=y)\\ &=\sum_y\sum_x x\,p_{X,Y}(x,y)\\ &=\sum_x x\sum_y p_{X,Y}(x,y)\\ &=\sum_x xP(X=x)\\ &=E[X]. \end{aligned} $$

The key step is cancellation of \(P(Y=y)\) in the conditional probability formula: multiplying \(P(X=x\mid Y=y)\) by \(P(Y=y)\) recovers the joint probability. The inner sum over \(y\) is the marginal probability \(P(X=x)\). The condition \(E[|X|]<\infty\) ensures that the sums can be rearranged without an ambiguity from an undefined difference of infinite positive and negative parts.

Worked Example: Recovering a Mean From a Joint Probability Table

A hypothetical insurer classifies a randomly selected policy as low-risk (\(Y=L\)) or high-risk (\(Y=H\)). Let \(X\) be the number of claims reported by that policy during a specified year. The joint probabilities are shown below. Find \(E[X\mid Y=L]\), \(E[X\mid Y=H]\), and \(E[X]\), then verify the law of iterated expectation.

Risk class \(Y\)\(P(X=0,Y)\)\(P(X=1,Y)\)\(P(X=2,Y)\)\(P(Y)\)
\(L\)0.200.100.100.40
\(H\)0.100.300.200.60

Method and condition check. This is a finite discrete distribution, so each expectation is a probability-weighted sum. The joint probabilities add to \(0.20+0.10+0.10+0.10+0.30+0.20=1.00\); \(X\) is bounded between 0 and 2, so \(E[|X|]<\infty\).

Low-risk conditional mean. Divide each joint probability in the \(L\) row by \(P(Y=L)=0.40\). Thus the conditional probabilities for \(X=0,1,2\) are \(0.20/0.40=0.50\), \(0.10/0.40=0.25\), and \(0.10/0.40=0.25\). Therefore,

$$ E[X\mid Y=L]=0(0.50)+1(0.25)+2(0.25)=0+0.25+0.50=0.75. $$

High-risk conditional mean. Divide the \(H\) row by \(P(Y=H)=0.60\). The conditional probabilities are \(0.10/0.60=1/6\), \(0.30/0.60=1/2\), and \(0.20/0.60=1/3\). Hence,

$$ E[X\mid Y=H]=0(1/6)+1(1/2)+2(1/3)=1/2+2/3=7/6. $$

Average the conditional means. Weight the two results by their class probabilities:

$$ E[E[X\mid Y]] =0.40(0.75)+0.60(7/6) =0.30+0.70 =1.00. $$

Direct check. The marginal probabilities are \(P(X=0)=0.20+0.10=0.30\), \(P(X=1)=0.10+0.30=0.40\), and \(P(X=2)=0.10+0.20=0.30\). Thus \(E[X]=0(0.30)+1(0.40)+2(0.30)=1.00\), matching the iterated expectation. The method avoids the common mistake of treating a conditional mean as the overall mean without weighting it by the probability of its conditioning class.

Derivation for Continuous Random Variables

Now suppose \((X,Y)\) has a joint density \(f_{X,Y}(x,y)\), and suppose \(E[|X|]<\infty\). Where the marginal density \(f_Y(y)\) is positive, the conditional density is \(f_{X\mid Y}(x\mid y)=f_{X,Y}(x,y)/f_Y(y)\). The conditional mean is the integral of \(x\) against this density. Substituting this definition and using \(f_{X,Y}(x,y)=f_{X\mid Y}(x\mid y)f_Y(y)\) gives

$$ \begin{aligned} E[E[X\mid Y]] &=\int E[X\mid Y=y]f_Y(y)\,dy\\ &=\int\left(\int x f_{X\mid Y}(x\mid y)\,dx\right)f_Y(y)\,dy\\ &=\int\int x f_{X,Y}(x,y)\,dx\,dy\\ &=\int x f_X(x)\,dx\\ &=E[X]. \end{aligned} $$

The joint density is zero outside its support, so the double integral covers only possible pairs \((x,y)\). The change in order of integration is justified by absolute integrability: \(\int\int |x|f_{X,Y}(x,y)\,dx\,dy=E[|X|]<\infty\). Also, the conditional mean is integrable because

$$ E\!\left[\,|E[X\mid Y]|\,\right] \leq E[|X|]<\infty. $$

This inequality follows because the absolute value of a conditional average cannot exceed the conditional average of the absolute value. Thus both sides of the law are finite under the stated condition.

Worked Example: Conditioning on a Continuous Measurement

For a hypothetical model, let \(X\) and \(Y\) have joint density \(f_{X,Y}(x,y)=2\) on \(0<x<y<1\), and zero elsewhere. Find \(E[X\mid Y=y]\), then use it to calculate \(E[X]\). Check the result by integrating the joint density directly.

Method and condition check. The support is a triangle of area \(1/2\), so the density integrates to \(2(1/2)=1\). Since \(0<X<1\), \(E[|X|]\leq 1\), and the required integrability condition holds.

Find the marginal density of \(Y\). For fixed \(y\) between 0 and 1, \(x\) ranges from 0 to \(y\). Therefore,

$$ f_Y(y)=\int_0^y 2\,dx=2y,\qquad 0<y<1. $$

Find the conditional density and mean. For \(0<y<1\), divide the joint density by \(f_Y(y)\):

$$ f_{X\mid Y}(x\mid y)=\frac{2}{2y}=\frac{1}{y},\qquad 0<x<y. $$

The conditional density is uniform over \((0,y)\), and direct integration gives

$$ E[X\mid Y=y]=\int_0^y x\frac{1}{y}\,dx =\frac{1}{y}\left[\frac{x^2}{2}\right]_0^y =\frac{y}{2}. $$

Average over \(Y\). Using the marginal density,

$$ E[E[X\mid Y]] =\int_0^1 \frac{y}{2}(2y)\,dy =\int_0^1 y^2\,dy =\left[\frac{y^3}{3}\right]_0^1 =\frac{1}{3}. $$

Direct check. Integrate \(x\) against the joint density over its triangular support:

$$ E[X]=\int_0^1\int_0^y 2x\,dx\,dy =\int_0^1 \left[x^2\right]_0^y\,dy =\int_0^1 y^2\,dy =\frac{1}{3}. $$

The direct calculation agrees with the iterated expectation. A common error is to average \(y/2\) using a uniform density for \(Y\). The marginal density is \(2y\), not 1; using the correct marginal is essential.

Finite Mixtures and the Meaning of the Weights

When \(Y\) is a category, \(E[X\mid Y]\) is a category-specific mean. The unconditional mean is the weighted average of those means, with weights \(P(Y=y)\). The weights must reflect how frequently each category occurs in the population or model. They are not generally equal, and they are not the conditional probabilities within a category.

Worked Example: Combining Conditional Claim-Payment Means

A hypothetical portfolio has two contract types, \(Y=A\) and \(Y=B\), with \(P(Y=A)=0.25\) and \(P(Y=B)=0.75\). Let \(X\) be the annual claim payment, in thousands of dollars. Conditional on type \(A\), \(X\) is 0, 2, or 8 with probabilities 0.50, 0.25, and 0.25. Conditional on type \(B\), those same amounts have probabilities 0.70, 0.20, and 0.10. Find the overall expected payment and verify it using the marginal distribution.

Method and condition check. Apply the law of iterated expectation, then check by calculating the mixture probabilities. The payment is bounded between 0 and 8 thousand dollars, so it is integrable.

Conditional means. For type \(A\),

$$ E[X\mid Y=A]=0(0.50)+2(0.25)+8(0.25)=0+0.50+2.00=2.50. $$

For type \(B\),

$$ E[X\mid Y=B]=0(0.70)+2(0.20)+8(0.10)=0+0.40+0.80=1.20. $$

Weight by contract type. The probabilities \(0.25\) and \(0.75\) give

$$ E[X]=0.25(2.50)+0.75(1.20)=0.625+0.900=1.525 $$

Thus the expected annual payment is 1.525 thousand dollars, or $1,525.00.

Marginal-distribution check. The joint mixture gives \(P(X=0)=0.25(0.50)+0.75(0.70)=0.125+0.525=0.650\); \(P(X=2)=0.25(0.25)+0.75(0.20)=0.0625+0.1500=0.2125\); and \(P(X=8)=0.25(0.25)+0.75(0.10)=0.0625+0.0750=0.1375\). These probabilities sum to \(0.6500+0.2125+0.1375=1.0000\). Hence,

$$ E[X]=0(0.650)+2(0.2125)+8(0.1375)=0+0.425+1.100=1.525. $$

The two methods agree. The exam trap is to take the simple average \((2.50+1.20)/2=1.85\), which incorrectly assigns equal portfolio weight to the two contract types.

When the Identity Applies

The standard finite-mean version requires \(E[|X|]<\infty\). This condition is stronger than merely writing down a conditional mean for some values of \(Y\): it ensures that \(E[X]\) exists as a finite number and that the conditional means can be averaged without an undefined rearrangement of infinite quantities. A useful sufficient check is that \(X\) is bounded; more generally, verify that the expectation of its absolute value is finite.

If \(X\) is nonnegative, the corresponding equality holds in the extended sense, allowing both sides to be \(+\infty\). That is not a finite-mean conclusion. For a signed random variable with infinite positive and negative parts, \(E[X]\) may be undefined, and the finite law cannot be invoked to assign it a value. Always check integrability before using the identity as an equation between finite expectations.

1
Check existence.
Confirm that \(E[|X|]<\infty\) when a finite unconditional mean is required.
2
Compute the conditional mean.
Use a conditional probability mass function for discrete conditioning or a conditional density for continuous conditioning.
3
Average with the law of \(Y\).
Use \(P(Y=y)\) as weights in a discrete sum or \(f_Y(y)\) in an integral.
4
Check the result.
When practical, compute the marginal distribution of \(X\) and evaluate \(E[X]\) directly.

The law is a basic consistency principle for conditional calculations and is aligned with the SOA VEE Mathematical Statistics syllabus. It does not say that every conditional mean equals the unconditional mean; it says that their properly weighted average does. The distinction matters whenever the conditioning groups have different probabilities or a continuous conditioning variable has a nonuniform marginal density.

Check Your Understanding

For each problem, check both the conditional calculation and the weights used to average it.

  1. A hypothetical portfolio has \(P(Y=A)=0.30\) and \(P(Y=B)=0.70\). Given \(A\), a claim count \(X\) is 0, 4, or 10 with probabilities 0.20, 0.50, and 0.30. Given \(B\), it is 0, 4, or 10 with probabilities 0.10, 0.20, and 0.70. Find \(E[X\mid A]\), \(E[X\mid B]\), and \(E[X]\). (Answer: \(E[X\mid A]=5\), \(E[X\mid B]=7.8\), and \(E[X]=6.96\).)
  2. Let \(X,Y\) have density \(2\) on \(0<y<x<1\) and zero elsewhere. Find \(E[Y\mid X=x]\) and then \(E[Y]\). (Answer: \(E[Y\mid X=x]=x/2\) and \(E[Y]=1/3\).)
  3. A hypothetical service-cost variable \(X\), in dollars, has conditional means \(E[X\mid Y=1]=15\), \(E[X\mid Y=2]=8\), and \(E[X\mid Y=3]=2\). If the three conditioning probabilities are 0.20, 0.50, and 0.30, find \(E[X]\). (Answer: \(7.6\) dollars.)
  4. Let \(P(X=n)=c/n^2\) and \(P(X=-n)=c/n^2\) for every positive integer \(n\), where \(c\) is the positive constant that makes the probabilities sum to 1. Set \(Y=X\). Is the finite-mean law applicable, and is \(E[X]\) defined? (Answer: No; \(E[|X|]=2c\sum_{n=1}^{\infty}1/n=\infty\), and the positive and negative parts both have infinite expectation, so \(E[X]\) is undefined.)
  5. A hypothetical portfolio has \(P(Y=C)=0.40\) and \(P(Y=D)=0.60\). Given \(C\), a payment \(X\) is 0 or 5 thousand dollars with probabilities 0.80 and 0.20; given \(D\), it is 0 or 5 thousand dollars with probabilities 0.30 and 0.70. Find the conditional means and the overall mean, in thousands of dollars. (Answer: \(E[X\mid C]=1\), \(E[X\mid D]=3.5\), and \(E[X]=2.5\) thousand dollars.)
Clinical Biostats