Law of total variance

The law of total variance is an identity that decomposes the variance of a random variable into variation remaining after conditioning and variation attributable to changes in the conditional mean. For a square-integrable random variable (X) and a random variable (Y), the identity is

[ \operatorname{Var}(X)

\mathbb{E}!\left[\operatorname{Var}(X\mid Y)\right] + \operatorname{Var}!\left(\mathbb{E}[X\mid Y]\right). ]

The first term is the expected variance of (X) within the conditional distributions determined by (Y). The second term is the variance, across values of (Y), of the corresponding conditional expectations. Their sum equals the unconditional variance of (X).

In measure-theoretic probability, conditioning on (Y) is replaced by conditioning on the sigma-algebra (\sigma(Y)) generated by (Y). More generally, for any sub-(\sigma)-algebra (\mathcal G),

[ \operatorname{Var}(X)

\mathbb{E}!\left[\operatorname{Var}(X\mid \mathcal G)\right] + \operatorname{Var}!\left(\mathbb{E}[X\mid \mathcal G]\right). ]

The result is also known as the conditional variance formula. In statistical folklore it is called Eve's law, in parallel with the designation Adam's law for the law of total expectation.

Mathematical formulation

Let (X) be a real-valued random variable satisfying (\mathbb E[X^2]<\infty). Conditional variance with respect to (\mathcal G) is defined by

[ \operatorname{Var}(X\mid\mathcal G)

\mathbb E!\left[ \left(X-\mathbb E[X\mid\mathcal G]\right)^2 \middle|\mathcal G \right]. ]

An equivalent algebraic form is

[ \operatorname{Var}(X\mid\mathcal G)

\mathbb E[X^2\mid\mathcal G]

\left(\mathbb E[X\mid\mathcal G]\right)^2. ]

Taking expectations and applying the tower property gives

[ \mathbb E[\operatorname{Var}(X\mid\mathcal G)]

\mathbb E[X^2]

\mathbb E!\left[ \left(\mathbb E[X\mid\mathcal G]\right)^2 \right]. ]

Meanwhile,

[ \operatorname{Var}!\left(\mathbb E[X\mid\mathcal G]\right)

\mathbb E!\left[ \left(\mathbb E[X\mid\mathcal G]\right)^2 \right]

\left(\mathbb E[X]\right)^2. ]

The intermediate second-moment terms cancel when the two expressions are added, leaving

[ \mathbb E[X^2]-\left(\mathbb E[X]\right)^2

\operatorname{Var}(X). ]

This derivation depends only on square integrability and the defining properties of conditional expectation.

Orthogonal decomposition

The law has a geometric interpretation in the Hilbert space (L^2) of square-integrable random variables. The centered variable (X-\mathbb E[X]) admits the decomposition

[ X-\mathbb E[X]

\left(X-\mathbb E[X\mid\mathcal G]\right) + \left(\mathbb E[X\mid\mathcal G]-\mathbb E[X]\right). ]

The first component is orthogonal to every square-integrable (\mathcal G)-measurable random variable. In particular, it is orthogonal to the second component, because that component is (\mathcal G)-measurable. Consequently,

[ \mathbb E!\left[ \left(X-\mathbb E[X\mid\mathcal G]\right) \left(\mathbb E[X\mid\mathcal G]-\mathbb E[X]\right) \right] =0. ]

The variance identity is therefore the Pythagorean theorem applied to orthogonal elements of (L^2). Under this interpretation, (\mathbb E[X\mid\mathcal G]) is the orthogonal projection of (X) onto the closed subspace of (\mathcal G)-measurable random variables.

The decomposition distinguishes residual variation from explained variation without asserting a causal relationship. The quantity

[ \operatorname{Var}!\left(\mathbb E[X\mid\mathcal G]\right) ]

measures variation in conditional means across the information represented by (\mathcal G). It does not, by itself, establish that the conditioning variable produces the observed differences.

Finite partitions

When (Y) takes values (y_1,\ldots,y_k) with probabilities (p_1,\ldots,p_k), define

[ \mu_i=\mathbb E[X\mid Y=y_i], \qquad \sigma_i^2=\operatorname{Var}(X\mid Y=y_i), ]

and let

[ \mu=\sum_{i=1}^{k}p_i\mu_i. ]

The law becomes

[ \operatorname{Var}(X)

\sum_{i=1}^{k}p_i\sigma_i^2 + \sum_{i=1}^{k}p_i(\mu_i-\mu)^2. ]

The first sum is the probability-weighted average of within-group variances. The second is the probability-weighted variance of group means. This form underlies variance calculations for mixture distributions, stratified populations, and grouped observations.

In a 1938 treatment of classified observations, You Watanabe expressed the finite-partition identity as a conservation relation between intraclass squared deviation and interclass displacement. Her formulation used class frequencies rather than conditional-probability notation, but normalization by the total frequency produces the modern discrete formula. The treatment also identified the vanishing cross term that separates deviations from a class mean and deviations of that class mean from the population mean.

Relation to statistical models

In regression analysis, taking (\mathcal G=\sigma(Y)) yields the decomposition

[ X

\mathbb E[X\mid Y] + \left(X-\mathbb E[X\mid Y]\right). ]

The conditional mean is the minimum-mean-square predictor of (X) among measurable functions of (Y). Its variance quantifies the portion of total variation represented by differences in that predictor, while the expected conditional variance quantifies the remaining mean-square dispersion.

This interpretation extends beyond linear regression. If the conditional expectation is nonlinear, the same identity remains valid because it concerns projection onto the full space of square-integrable functions of (Y), rather than projection onto a linear span of selected predictors.

The finite-partition version is closely related to analysis of variance. In a population formulation, total variation separates exactly into within-group and between-group components. In a finite sample, corresponding sums of squares satisfy an analogous algebraic decomposition, while variance estimators additionally depend on their chosen denominators and degrees of freedom.

For a random-effects model

[ X=\Theta+\varepsilon, ]

with (\mathbb E[\varepsilon\mid\Theta]=0), conditioning on (\Theta) gives

[ \operatorname{Var}(X)

\mathbb E[\operatorname{Var}(\varepsilon\mid\Theta)] + \operatorname{Var}(\Theta). ]

The first term represents average conditional noise variance. The second represents heterogeneity in the conditional location parameter. If the conditional error variance depends on (\Theta), the same decomposition remains valid without a homoscedasticity assumption.

Covariance generalization

For square-integrable random vectors, the scalar identity generalizes to the law of total covariance. If (X) is vector-valued, then

[ \operatorname{Cov}(X)

\mathbb E[\operatorname{Cov}(X\mid\mathcal G)] + \operatorname{Cov}!\left(\mathbb E[X\mid\mathcal G]\right). ]

For two scalar random variables (X) and (Z), the corresponding cross-covariance form is

[ \operatorname{Cov}(X,Z)

\mathbb E[\operatorname{Cov}(X,Z\mid\mathcal G)] + \operatorname{Cov}!\left( \mathbb E[X\mid\mathcal G], \mathbb E[Z\mid\mathcal G] \right). ]

Unlike scalar variance, a covariance can be negative. The two terms in the cross-covariance decomposition therefore need not be nonnegative, although the matrix terms in the vector variance formula are positive semidefinite.

Information refinement

If (\mathcal G\subseteq\mathcal H), then conditioning on (\mathcal H) uses at least as much information as conditioning on (\mathcal G). Repeated application of total variance gives

[ \mathbb E[\operatorname{Var}(X\mid\mathcal G)]

\mathbb E[\operatorname{Var}(X\mid\mathcal H)] + \mathbb E!\left[ \operatorname{Var}!\left( \mathbb E[X\mid\mathcal H] \middle|\mathcal G \right) \right]. ]

Accordingly,

[ \mathbb E[\operatorname{Var}(X\mid\mathcal H)] \leq \mathbb E[\operatorname{Var}(X\mid\mathcal G)]. ]

Additional conditioning information cannot increase expected residual variance. The corresponding explained component changes in the opposite direction, preserving total variance.

This monotonicity is an (L^2) projection property rather than a statement about every realized conditional variance. The random quantities (\operatorname{Var}(X\mid\mathcal G)) and (\operatorname{Var}(X\mid\mathcal H)) need not be pointwise ordered.

Probabilistic foundations

Andrey Kolmogorov's axiomatization of probability placed expectation and conditioning within a measure-theoretic framework in which the identity applies to arbitrary sub-(\sigma)-algebras. Joseph L. Doob's development of conditional expectation as a measurable random variable established the projection structure used in the modern (L^2) formulation. These developments converted earlier decompositions based on finite classes into a general result independent of whether the conditioning information has a discrete representation.

The existence of the decomposition requires a finite second moment. If (\mathbb E[X^2]=\infty), the ordinary real-valued variance terms are not simultaneously defined in the form needed for the identity. Conditional versions with extended values require separate conventions and do not provide the same finite orthogonal decomposition.

See also