Actuarial Statistics · Expectations and conditional expectations
Law of Total Expectation and Total Variance Explained
Updated 11 October 2026 · Fact-checked
The law of total expectation says E[X] = E[E[X | Y]]. The law of total variance says Var(X) = E[Var(X | Y)] + Var(E[X | Y]). To solve a question, find the conditional mean and variance given Y, then take the mean and variance of those over Y's distribution.
Understand Law of Total Expectation and Total Variance
Many random quantities are easier to handle in two stages. First a quantity Y is chosen, such as the number of claims or the type of policyholder. Then X is generated given Y. Conditioning on Y lets you work with a simpler problem at each stage.
E[X | Y] is itself a random variable. It is a function of Y. If Y = y, it takes the value E[X | Y = y]. Because it is random, you can take its expectation and its variance. The tower property says that averaging the conditional means over Y gives the overall mean: E[X] = E[E[X | Y]].
The variance has two sources. Part of the spread of X comes from the randomness of X within each value of Y. This is measured by E[Var(X | Y)], the average conditional variance. The rest comes from the fact that the conditional mean moves around as Y changes. This is measured by Var(E[X | Y]). Add the two parts to get Var(X).
This is the standard tool for compound distributions and mixtures. For a compound sum S = X₁ + ... + X_N, with N independent of the Xᵢ, which are independent and identically distributed, you condition on N. For a mixture, such as a Poisson whose mean λ is itself random, you condition on the parameter. The same idea underlies Bayesian and credibility models.
The laws need the relevant moments to exist and be finite. They hold whether Y is discrete or continuous.
Key rules to remember
- Law of total expectation (tower property)
- E[X] = E[E[X | Y]]
- Needs E[X] to exist. Y can be discrete or continuous.
- Law of total variance
- Var(X) = E[Var(X | Y)] + Var(E[X | Y])
- Needs Var(X) to be finite. First term is the average conditional variance. Second is the variance of the conditional mean.
- Compound sum mean
- E[S] = E[N] × E[X]
- S = X₁ + ... + X_N, N independent of the Xᵢ, Xᵢ identically distributed.
- Compound sum variance
- Var(S) = E[N] × Var(X) + Var(N) × (E[X])²
- Same conditions. It comes from E[Var(S | N)] = E[N]Var(X) and Var(E[S | N]) = Var(N)(E[X])², using independent Xᵢ.
- Conditional moments of a compound sum
- E[S | N] = N × E[X], Var(S | N) = N × Var(X)
- Valid when the Xᵢ are independent and identically distributed and independent of N.
- Variance from conditional variance definition
- Var(X | Y) = E[X² | Y] − (E[X | Y])²
- Use it to find conditional variance when only conditional moments are given.
How to solve Law of Total Expectation and Total Variance questions
Use this method for any compound, mixture or two-stage question.
- 1Identify the variable Y to condition on. Choose the one that makes X simple once Y is known, such as the claim count N or the parameter θ.
- 2Write down the distribution of X given Y and find E[X | Y] and Var(X | Y) as functions of Y.
- 3Find E[X] by taking the expectation of E[X | Y] over the distribution of Y.
- 4Find E[Var(X | Y)] by taking the expectation of the conditional variance over Y. This often needs E[Y] or E[Y²].
- 5Find Var(E[X | Y]) by taking the variance of the conditional mean over Y. If E[X | Y] = aY + b, this is a² Var(Y).
- 6Add the two parts to get Var(X). Check that the answer is positive and that each part is non-negative.
- 7State the result with the assumptions used, such as independence of N and the Xᵢ.
Quickest way: Compound sum shortcut
When to use it: Use it when S is a sum of a random number N of independent, identically distributed claims, with N independent of the claims.
- Write the four inputs: E[N], Var(N), E[X], Var(X).
- Compute E[S] = E[N]E[X].
- Compute Var(S) = E[N]Var(X) + Var(N)(E[X])².
- For a Poisson N with mean λ, use Var(S) = λE[X²], since E[N] = Var(N) = λ.
- In a written answer, still show the conditioning in one line so the method earns marks.
Common mistakes in Law of Total Expectation and Total Variance
Writing Var(X) = E[Var(X | Y)] and forgetting the second term.
Students treat the average conditional variance as the total variance.
Fix: Always write both terms first, then compute each. The second term is zero only if E[X | Y] is constant.
Using Var(N)E[X] instead of Var(N)(E[X])².
The square is dropped when scaling a variance.
Fix: Var(aN) = a² Var(N). Here a = E[X], so square it.
Treating Var(X | Y) as a constant and taking it outside the expectation.
Students forget that conditional variance depends on Y.
Fix: Keep it as a function of Y, such as N Var(X), then take E over Y.
Using E[N²] as Var(N) when finding the variance of the conditional mean.
Mixing up the second moment and the variance.
Fix: Var(N) = E[N²] − (E[N])². Use the variance, not E[N²], in Var(E[S | N]).
Applying the compound formulas when N and the claims are not independent.
The formulas are memorised without their conditions.
Fix: Check the independence statement in the question. If it fails, go back to conditioning from first principles.
Taking E[X | Y] as a number rather than a random variable.
The notation looks like an ordinary expectation.
Fix: Remember it is a function of Y. It has its own mean and variance.
Worked examples
Example 1
The number of claims N in a year has mean 4 and variance 6. Each claim amount X has mean ₹10,000 and standard deviation ₹5,000. Claims are independent and identically distributed, and independent of N. Find the mean and standard deviation of annual aggregate claims S. Give the standard deviation to the nearest rupee.
Show the solution
- Condition on N: E[S | N] = 10,000N and Var(S | N) = N × 5,000² = 25,000,000N.
- E[S] = E[10,000N] = 10,000 × 4 = ₹40,000.
- E[Var(S | N)] = 25,000,000 × E[N] = 25,000,000 × 4 = 100,000,000.
- Var(E[S | N]) = 10,000² × Var(N) = 100,000,000 × 6 = 600,000,000.
- Var(S) = 100,000,000 + 600,000,000 = 700,000,000.
- SD(S) = √700,000,000 = 10,000 × √7 ≈ 10,000 × 2.64575 = 26,457.5, so about ₹26,458.
Answer: E[S] = ₹40,000 and SD(S) ≈ ₹26,458.
Example 2
Given Λ, the number of claims X is Poisson with mean Λ. Λ is uniformly distributed on (0, 6). Find E[X] and Var(X).
Show the solution
- Given Λ, E[X | Λ] = Λ and Var(X | Λ) = Λ.
- For Λ uniform on (0, 6): E[Λ] = 3 and Var(Λ) = 6² ÷ 12 = 3.
- E[X] = E[Λ] = 3.
- E[Var(X | Λ)] = E[Λ] = 3.
- Var(E[X | Λ]) = Var(Λ) = 3.
- Var(X) = 3 + 3 = 6.
Answer: E[X] = 3 and Var(X) = 6. The variance exceeds the mean because the Poisson parameter is itself random.
Exam tips
- Write the law of total variance with both terms before substituting. Marks are often given for the correct structure.
- In compound questions, state the independence assumption explicitly. Examiners reward it.
- In MCQs, check quickly whether the question is Poisson compound. Var(S) = λE[X²] saves time.
- If given E[X²] rather than Var(X), convert first: Var(X) = E[X²] − (E[X])².
- For mixtures, a variance larger than the mean in a Poisson mixture is a good sense check.
Practice questions from Expectations and conditional expectations
- X and Y have joint density f(x,y) = 2 for 0 < y < x < 1, and 0 otherwise. What is Var(Y | X = x) for 0 < x < 1?
- A random variable X takes the values 0, 1, 2 and 4 with probabilities 0.1, 0.3, 0.4 and 0.2 respectively. What is E[X]?
- X and Y are random variables with Var(X) = 16, Var(Y) = 25 and correlation coefficient −0.5. What is Var(3X − 2Y)?
- The number of claims N on a policy in a year is Poisson with mean 3. Each claim is independently of size with mean Rs 20,000 and variance Rs…
- Let N be Poisson with mean 3, and given N = n, S is the sum of n independent claims each with mean 100 and variance 400 (S = 0 if n = 0). Wh…
Law of Total Expectation and Total Variance: frequently asked questions
What is the difference between E[X | Y] and E[X | Y = y]?
E[X | Y = y] is a number for a fixed value y. E[X | Y] is a random variable that takes the value E[X | Y = y] when Y = y. You can take its mean and variance, which is what the two laws do.
Why is there a second term in the law of total variance?
X varies within each value of Y and also because its conditional mean changes with Y. The first term captures the within-group spread. The second captures the spread between groups.
Can I use the compound variance formula if claim sizes are not identically distributed?
Not directly. The formula Var(S) = E[N]Var(X) + Var(N)(E[X])² needs identically distributed claims. Otherwise condition on N and work from first principles.
Does the law of total expectation work when Y is continuous?
Yes. The expectation over Y becomes an integral with Y's density. The statement E[X] = E[E[X | Y]] is the same.