Law of total variance

From HandWiki
Short description: Theorem in probability theory


The law of total variance is a fundamental result in probability theory that expresses the variance of a random variable Y in terms of its conditional variances and conditional means given another random variable X. Informally, it states that the overall variability of Y can be split into an “unexplained” component (the average of within-group variances) and an “explained” component (the variance of group means).

Formally, if X and Y are random variables on the same probability space, and Y has finite variance, then:

Var⁡(Y)=E⁡[Var⁡(Y∣X)]+Var⁡(E⁡[Y∣X]).

This identity is also known as the variance decomposition formula, the conditional variance formula, the law of iterated variances, or colloquially as Eve’s law,[1] in parallel to the “Adam’s law” naming for the law of total expectation.

In actuarial science (particularly in credibility theory), the two terms E⁡[Var⁡(Y∣X)] and Var⁡(E⁡[Y∣X]) are called the expected value of the process variance (EVPV) and the variance of the hypothetical means (VHM) respectively.[2]

Explanation

Let Y be a random variable and X another random variable on the same probability space. The law of total variance can be understood by noting:

  1. Var⁡(Y∣X) measures how much Y varies around its conditional mean E⁡[Y∣X].
  2. Taking the expectation of this conditional variance across all values of X gives E⁡[Var⁡(Y∣X)], often termed the “unexplained” or within-group part.
  3. The variance of the conditional mean, Var⁡(E⁡[Y∣X]), measures how much these conditional means differ (i.e. the “explained” or between-group part).

Adding these components yields the total variance Var⁡(Y), mirroring how analysis of variance partitions variation.

Examples

Example 1 (Exam Scores)

Suppose five students take an exam scored 0–100. Let Y = student’s score and X indicate whether the student is *international* or *domestic*:

Student Y (Score) X
1 20 International
2 30 International
3 100 International
4 40 Domestic
5 60 Domestic
  • Mean and variance for international: E⁡[Y∣X=Intl]=50,Var⁡(Y∣X=Intl)≈1266.7.
  • Mean and variance for domestic: E⁡[Y∣X=Dom]=50,Var⁡(Y∣X=Dom)=100.

Both groups share the same mean (50), so the explained variance Var⁡(E⁡[Y∣X]) is 0, and the total variance equals the average of the within-group variances (weighted by group size), i.e. 800.

Example 2 (Mixture of Two Gaussians)

Let X be a coin flip taking values Heads with probability h and Tails with probability 1−h. Given Heads, Y∼Normal(μh,σh2); given Tails, Y∼Normal(μt,σt2). Then E⁡[Var⁡(Y∣X)]=hσh2+(1−h)σt2, Var⁡(E⁡[Y∣X])=h(1−h)(μh−μt)2, so Var⁡(Y)=hσh2+(1−h)σt2+h(1−h)(μh−μt)2.

Example 3 (Dice and Coins)

Consider a two-stage experiment:

  1. Roll a fair die (values 1–6) to choose one of six biased coins.
  2. Flip that chosen coin; let Y=1 if Heads, 0 if Tails.

Then E⁡[Y∣X=i]=pi,Var⁡(Y∣X=i)=pi(1−pi). The overall variance of Y becomes Var⁡(Y)=E⁡[pX(1−pX)]+Var⁡(pX), with pX uniform on {p1,…,p6}.

Proof

Discrete/Finite Proof

Let (Xi,Yi), i=1,…,n, be observed pairs. Define Y‾=E⁡[Y]. Then Var⁡(Y)=1n∑i=1n(Yi−Y‾)2=1n∑i=1n[(Yi−Y‾Xi)+(Y‾Xi−Y‾)]2, where Y‾Xi=E⁡[Y∣X=Xi]. Expanding the square and noting the cross term cancels in summation yields: Var⁡(Y)=E⁡[Var⁡(Y∣X)]+Var⁡(E⁡[Y∣X]).

General Case

Using Var⁡(Y)=E⁡[Y2]−E⁡[Y]2 and the law of total expectation: E⁡[Y2]=E⁡[E⁡(Y2∣X)]=E⁡[Var⁡(Y∣X)+E⁡[Y∣X]2]. Subtract E⁡[Y]2=(E⁡[E⁡(Y∣X)])2 and regroup to arrive at Var⁡(Y)=E⁡[Var⁡(Y∣X)]+Var⁡(E⁡[Y∣X]).

Applications

Analysis of Variance (ANOVA)

In a one-way analysis of variance, the total sum of squares (proportional to Var⁡(Y)) is split into a “between-group” sum of squares (Var⁡(E⁡[Y∣X])) plus a “within-group” sum of squares (E⁡[Var⁡(Y∣X)]). The F-test examines whether the explained component is sufficiently large to indicate X has a significant effect on Y.[3]

Regression and R²

In linear regression and related models, if Y^=E⁡[Y∣X], the fraction of variance explained is R2=Var⁡(Y^)Var⁡(Y)=Var⁡(E⁡[Y∣X])Var⁡(Y)=1−E⁡[Var⁡(Y∣X)]Var⁡(Y). In the simple linear case (one predictor), R2 also equals the square of the Pearson correlation coefficient between X and Y.

Machine Learning and Bayesian Inference

In many Bayesian and ensemble methods, one decomposes prediction uncertainty via the law of total variance. For a Bayesian neural network with random parameters θ: Var⁡(Y)=E⁡[Var⁡(Y∣θ)]+Var⁡(E⁡[Y∣θ]), often referred to as “aleatoric” (within-model) vs. “epistemic” (between-model) uncertainty.[4]

Actuarial Science

Credibility theory uses the same partitioning: the expected value of process variance (EVPV), E⁡[Var⁡(Y∣X)], and the variance of hypothetical means (VHM), Var⁡(E⁡[Y∣X]). The ratio of explained to total variance determines how much “credibility” to give to individual risk classifications.[2]

Information Theory

For jointly Gaussian (X,Y), the fraction Var⁡(E⁡[Y∣X])/Var⁡(Y) relates directly to the mutual information I(Y;X).[5] In non-Gaussian settings, a high explained-variance ratio still indicates significant information about Y contained in X.

Generalizations

The law of total variance generalizes to multiple or nested conditionings. For example, with two conditioning variables X1 and X2: Var⁡(Y)=E⁡[Var⁡(Y∣X1,X2)]+E⁡[Var⁡(E⁡[Y∣X1,X2]∣X1)]+Var⁡(E⁡[Y∣X1]). More generally, the law of total cumulance extends this approach to higher moments.

See also

References

  1. ↑ Joe Blitzstein and Jessica Hwang, Introduction to Probability, Final Review Notes.
  2. ↑ 2.0 2.1 Mahler, Howard C.; Dean, Curtis G. (2001). "Chapter 8: Credibility". in Casualty Actuarial Society. Foundations of Casualty Actuarial Science (4th ed.). Casualty Actuarial Society. pp. 525–526. ISBN 978-0-96247-622-8. http://people.stat.sfu.ca/~cltsai/ACMA315/Ch8_Credibility.pdf. Retrieved June 25, 2015. 
  3. ↑ Analysis of variance — R.A. Fisher’s 1920s development.
  4. ↑ See for instance AWS ML quantifying uncertainty guidance.
  5. ↑ C. G. Bowsher & P. S. Swain (2012). "Identifying sources of variation and the flow of information in biochemical networks," PNAS 109 (20): E1320–E1328.