Joint Distributions, Covariance & Correlation

the law of total (conditional) variance

The total uncertainty in a quantity can come from two sources: the spread WITHIN each scenario, and the spread BETWEEN scenarios as you change which one you are in. The law of total variance separates total variance cleanly into exactly these two pieces.

It says Var(X) = E[ Var(X given Y) ] + Var( E[X given Y] ). The first term, E[Var(X given Y)], is the average of the leftover variability of X once you have fixed Y — the within-group, unexplained spread. The second term, Var(E[X given Y]), is the variability of the conditional means themselves as Y varies — the between-group spread that knowing Y would explain. Both are non-negative, so total variance is always at least either piece. A handy memory: the mean of the conditional variances plus the variance of the conditional means.

This decomposition is the backbone of analysis of variance, of the idea of 'explained versus unexplained' variation in regression and prediction, and of mixed and hierarchical models. It quantifies how much of an outcome's uncertainty a predictor Y could in principle remove (the between-term) versus how much is irreducible noise given Y (the within-term). It is the natural companion to the law of total expectation — together they let you compute means and variances by conditioning.

Pick one of two factories at random; factory A's output has mean 100 and variance 4, factory B's has mean 120 and variance 9. The within term E[Var(X given Y)] = (4 + 9)/2 = 6.5. The between term is the variance of the two means 100 and 120 (each with probability 1/2), which is 100. Total Var(X) = 6.5 + 100 = 106.5 — most of the variability is between factories.

Total variance = average within-group variance + variance of the group means.

Both terms are non-negative, so conditioning on Y can never increase the average within-spread above the total — it can only move variance between the two boxes, never create it.

Also called
variance decompositionEve's law全變異數法則變異數分解