Interactive demo · Probability and Statistical Inference · Chapter 3

Conditional expectation and the law of total variance

A two-stage experiment first draws X, then draws Y from a distribution that depends on the value of X. The conditional mean E(Y | X = x) is a function of x (the line in the left panel); evaluated at the random X it becomes a random variable, E(Y | X), whose average is E(Y) (Theorem 3.24). The spread of Y has two sources: the spread around the line at a fixed x, averaged over x, and the movement of the line itself as x varies. Theorem 3.27 says the two simply add: V(Y) = E V(Y | X) + V E(Y | X).

Experiment

Number of people per county n

Proportion Q ~ Beta(a, b): a

b

Tails: Y ~ Uniform(d, d + 1), d

Number of repetitions R

Random numbers

Try these

The simulated terms use the exact conditional mean and variance at each simulated first stage: E V is the average of V(Y | X = xr) and V E the variance of E(Y | X = xr) over the R repetitions. Their sum is compared with the plain variance of the simulated Ys.

In the lecture notes