ArticleslgStudy

mathematics

Law of total variance

Law of total variance is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Law of total variance rather than just read about it. In short: 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).

Key takeaways

  • Law of total variance belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Law of total variance to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Law of total variance from memory before moving on to harder problems.

Reference excerpt

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, 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.

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:

Var⁡(Y∣X) measures how much Y varies around its conditional mean E⁡[Y∣X]. 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. 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*:

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:

Roll a fair die (values 1–6) to choose one of six biased coins. 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.

Regression and R² In linear regression and related models, if Ŷ=E⁡[Y∣X], the fraction of variance explained is R2=Var⁡(Ŷ)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.

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.

Information theory For jointly Gaussian (X,Y), the fraction Var⁡(E⁡[Y∣X])/Var⁡(Y) relates directly to the mutual information I(Y;X). 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

Worked examples

Example 1 — a first encounter with Law of total variance

Start with the simplest possible case. Write down what Law of total variance claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Law of total variance before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Law of total variance ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Law of total variance

In research
Law of total variance appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Law of total variance in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Law of total variance is common in secondary-school and first-year university syllabi. It links to neighbouring topics Algebra of random variables, Statistical deviation and dispersion, Statistical laws, so understanding it makes those chapters shorter.
In everyday life
Look for Law of total variance outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Law of total variance” →

How to study Law of total variance in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Law of total variance means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Law of total variance out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Law of total variance in simple terms?

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 "unexp…

Why does Law of total variance matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Law of total variance?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Law of total variance.

Tags

  • Algebra of random variables
  • Statistical deviation and dispersion
  • Statistical laws
  • Theorems in statistics
  • Theory of probability distributions

Keep exploring