Conditional Expectation and Total Variance
Average within each known group, then average across groups; split total variation into within-group and between-group parts.
Draft — not yet reviewed by the site owner.
Prerequisites: Conditional Distributions, Expected Value, Variance of a Random Variable.
A conditional expectation is the average value of a random quantity after some information is known. If we know which group a person belongs to, we can use that group’s average instead of the overall average. Averaging those group averages brings us back to the overall average.
Two stages of averaging
Let be the information we learn and the quantity we want to predict. For each possible , the number is the mean of the conditional distribution of given . As changes, this number changes, so is itself a random variable: a function of .
The law of total expectation, also called the tower property, says
provided is finite. First find the mean within each group. Then average those means, weighting each group by how likely it is. This is the same operation as summing the cells of a probability table in two stages.
A small example
Suppose a fair coin chooses a group. In group A, is equally likely to be 0 or 2. In group B, it is equally likely to be 2 or 4. Here is the chosen group.
| Group | Possible values | ||
|---|---|---|---|
| A | 0 or 2, equally likely | 1 | 1 |
| B | 2 or 4, equally likely | 3 | 1 |
Each group has probability , so the overall mean is . We could instead list all four equally likely outcomes, , and get the same answer. The two-stage calculation becomes more useful when there are many groups or a continuous random parameter.
Where the variance goes
The law of total variance separates two reasons can vary:
provided is finite. The first term is the average variation within the groups. The second is variation between the group means. In the example, the within-group variance is 1 in either group, so its average is 1. The group means are 1 and 3, equally likely, and their variance is also 1. The total is 2.
To see why the identity works, write and . Then
Square this expression and take expectations. The cross-term vanishes because . The two squared terms become the within-group and between-group variances above.
When this helps
If a model first draws a random parameter and then draws an outcome given that parameter, the conditional mean and variance are often easy to find even when the outcome’s full marginal distribution is hard. This is common in mixture models, prediction, and Bayesian calculations.
Do not confuse , a number for a fixed , with , a random variable before is observed. Nor should the two variance terms be swapped: one averages the conditional variances; the other measures the spread of conditional means.
Further reading
- MIT OpenCourseWare, “Conditional Expectation & Variance Revisited”. Public lesson on total expectation, total variance, and random sums.