STATISTICS GRADUATE LEVEL • PROOF, DERIVATION & PROBLEM-SOLVING TOOLS

Computing via Conditioning — Compute expectations and variances using conditioning

Harness the tower property and conditional variance decomposition to elegantly solve complex expectation and variance problems.

Historical Context & Motivation

The idea of computing expectations by first conditioning on auxiliary information has deep roots in the development of probability theory. Long before the formal measure-theoretic foundations were established, probabilists recognized that breaking a complex calculation into simpler conditional pieces was both natural and powerful. The law of total expectation and the law of total variance emerged as indispensable tools in the probabilist's repertoire, transforming seemingly intractable problems into manageable conditional calculations. Understanding the historical trajectory of these ideas illuminates why conditioning remains one of the most elegant and frequently deployed strategies in modern probability and statistics.

1812
Laplace's Iterated Expectation
Pierre-Simon Laplace employed iterated expectation arguments in his Théorie analytique des probabilités, decomposing probabilities and expectations over intermediate events to solve problems involving compound random phenomena.
1933
Kolmogorov's Axiomatization
Andrey Kolmogorov published his Grundbegriffe der Wahrscheinlichkeitsrechnung, providing a rigorous measure-theoretic definition of conditional expectation and establishing the tower property E[E[X|𝒢]|ℋ] = E[X|ℋ] for sub-σ-algebras ℋ ⊆ 𝒢.
1950s
Rao–Blackwell Theorem & Applications
The Rao–Blackwell theorem demonstrated that conditioning an estimator on a sufficient statistic never increases its variance, establishing conditional expectation as a fundamental tool in statistical estimation theory.
1968
Eve's Law Popularized
The law of total variance, often called the variance decomposition formula or 'Eve's law' (EVVE: E[Var] + Var[E]), became widely taught in graduate curricula as a standard technique for computing variances of compound and mixture distributions.
Modern
Ubiquity in Bayesian & Computational Statistics
Conditioning arguments now underpin Bayesian hierarchical models, Rao–Blackwellized particle filters, Gibbs samplers, and variance reduction techniques in Monte Carlo simulation, making 'computing via conditioning' an everyday workhorse in applied statistics.

The central question that conditioning addresses is straightforward yet profound: given a random variable X whose distribution depends on another random quantity Y, how can we systematically compute E[X] and Var(X) by leveraging what we know about the conditional distribution of X given Y? The two laws we will study provide a complete and elegant answer.

Core Principles & Definitions

Computing via conditioning rests on two foundational identities—the law of total expectation and the law of total variance—together with the concept of conditional expectation as a random variable. The key conceptual shift is recognizing that E[X|Y] is not a number but a function of the random variable Y, and therefore it is itself a random variable with its own expectation and variance. Mastering this conceptual point is the gateway to deploying the conditioning machinery fluently.

1

Conditional Expectation E[X|Y]

Given Y = y, the conditional expectation E[X|Y = y] is computed using the conditional distribution of X given Y = y. Viewed as a function of the random Y, E[X|Y] = g(Y) is a random variable.
2

Law of Total Expectation (Tower Property)

E[X] = E[E[X|Y]]. The outer expectation averages the conditional mean over the distribution of Y. This identity enables two-stage computation: first condition on Y, then average out.
3

Conditional Variance Var(X|Y)

Var(X|Y) = E[X²|Y] − (E[X|Y])² measures the residual variability in X that remains after observing Y. Like the conditional mean, it is a random variable—a function of Y.
4

Law of Total Variance (Eve's Law)

Var(X) = E[Var(X|Y)] + Var(E[X|Y]). Total variance decomposes into the mean of within-group variance plus the variance of group means, providing both a computational tool and a conceptual decomposition.
5

Strategy: Choose Y Wisely

The art of conditioning lies in selecting the right auxiliary variable Y so that E[X|Y] and Var(X|Y) become recognizable distributions. Good choices include mixture parameters, stopping times, or latent variables.
KEY TAKEAWAY
Think of conditioning like a two-phase survey. Suppose you want the average height across an entire university. Rather than measuring everyone at once, you first compute the average height within each department (the conditional mean), then take a weighted average across departments (the outer expectation). The law of total expectation guarantees this two-phase approach yields the correct overall average. The law of total variance goes further: total variability equals the average within-department spread plus the variability of department averages—neatly separating 'within-group' and 'between-group' variation.

Visual Explanation — The Conditioning Decomposition

The upper half illustrates the law of total expectation: start from the joint distribution, condition on each value of Y to obtain conditional means μₖ, then average over Y to recover E[X]. The lower half shows the total variance decomposition into within-group (purple) and between-group (pink) components.

The diagram above captures the essence of computing via conditioning. In the top half, observe how the joint distribution f(x, y) is partitioned by conditioning on different realized values of Y. Each conditional slice yields its own mean μₖ = E[X|Y = yₖ], and these conditional means are themselves random—they vary as Y varies. The final step applies the ordinary expectation operator to this random function g(Y) = E[X|Y], recovering the unconditional mean. The bottom half extends this logic to variance: the total variance of X is the average within-group variance (how much X spreads around its conditional mean for a fixed Y) plus the between-group variance (how much the conditional means themselves fluctuate as Y changes). This decomposition is both computationally useful and conceptually illuminating.

Mathematical Framework

Law of Total Expectation — Derivation

We begin with the discrete case for clarity. Let X and Y be jointly distributed discrete random variables. By the definition of marginal expectation and applying the law of total probability, we can decompose E[X] into a double sum that naturally factors via conditional distributions.

LAW OF TOTAL EXPECTATION (DISCRETE)
E[X] = Σ_y E[X | Y = y] · P(Y = y) = E_Y[E[X | Y]]
Proof sketch: E[X] = Σ_x x · P(X = x) = Σ_x x Σ_y P(X = x, Y = y) = Σ_y Σ_x x · P(X = x | Y = y) · P(Y = y) = Σ_y E[X|Y = y] · P(Y = y). The interchange of summation is justified by absolute convergence.
CONTINUOUS ANALOGUE
E[X] = ∫_{−∞}^{∞} E[X | Y = y] · f_Y(y) dy
Here f_Y(y) is the marginal density of Y. The conditional expectation E[X|Y = y] = ∫ x · f_{X|Y}(x|y) dx is evaluated for each fixed y, then integrated against the marginal density of Y.

Law of Total Variance — Derivation

The law of total variance follows from the definition of variance and two applications of the tower property. Write Var(X) = E[X²] − (E[X])². We condition on Y to expand each term and then carefully rearrange.

LAW OF TOTAL VARIANCE (EVE'S LAW)
Var(X) = E[Var(X | Y)] + Var(E[X | Y])
Derivation: Note Var(X|Y) = E[X²|Y] − (E[X|Y])². Taking outer expectations: E[Var(X|Y)] = E[X²] − E[(E[X|Y])²]. Also, Var(E[X|Y]) = E[(E[X|Y])²] − (E[E[X|Y]])² = E[(E[X|Y])²] − (E[X])². Adding these two: E[Var(X|Y)] + Var(E[X|Y]) = E[X²] − (E[X])² = Var(X). ∎
💡 Mnemonic: EVVE
A popular mnemonic for the law of total variance is EVVE: E of the V plus V of the E. Here, the first 'E' and 'V' refer to E[Var(X|Y)] (expected value of the conditional variance), while the second 'V' and 'E' refer to Var(E[X|Y]) (variance of the conditional expectation). The alternating E-V pattern makes it easy to recall.
TOWER PROPERTY (GENERAL FORM)
E[E[X | 𝒢] | ℋ] = E[X | ℋ] whenever ℋ ⊆ 𝒢
In the special case ℋ = {∅, Ω} (the trivial σ-algebra), this reduces to E[E[X|Y]] = E[X]. The tower property is the foundational identity from which both the law of total expectation and the law of total variance are derived.

Techniques & Common Conditioning Strategies

The power of computing via conditioning lies in the choice of the conditioning variable Y. Different problem structures suggest different natural choices, and recognizing these patterns is a skill honed through practice. Below we catalog the most frequently encountered strategies, along with a visual decision guide.

This decision tree guides the choice of conditioning variable. For mixture/hierarchical problems, condition on the random parameter Θ. For random sums S = X₁ + ⋯ + X_N, condition on the random count N. Other patterns include first-step analysis in Markov chains and indicator-based decompositions.
Common conditioning strategies and their typical application domains
StrategyCondition on Y =Typical Problem ClassExample
Mixture parameterΘ (latent parameter)Bayesian priors, overdispersed modelsX|Θ ~ Bin(n, Θ), Θ ~ Beta(a, b)
Random countN (number of terms)Compound Poisson, random walksS = X₁ + ⋯ + X_N, N ~ Poisson(λ)
First stepOutcome of first transitionGambler's ruin, Markov chain hitting timesE[T] = 1 + p·E[T|up] + q·E[T|down]
Indicator eventSuccess/failure of a sub-eventCoupon collector, matching problemsE[X] = E[X|A]P(A) + E[X|Aᶜ]P(Aᶜ)

Worked Example — Random Sum with a Poisson Count

An insurance company models the total claims S in a given month as a random sum S = X₁ + X₂ + ⋯ + X_N, where N ~ Poisson(λ = 10) is the number of claims and each claim size Xᵢ is independent and identically distributed with E[Xᵢ] = 500 and Var(Xᵢ) = 40,000. The Xᵢ are also independent of N. Compute E[S] and Var(S).

Computing E[S] and Var(S) via Conditioning on N
1
Step 1 — Identify the Conditioning VariableThe total claims S depends on the random count N. Conditioning on N transforms S into a fixed sum of i.i.d. random variables, which is far easier to analyze. We set Y = N and apply the laws of total expectation and total variance.
2
Step 2 — Compute E[S|N]Given N = n, the sum S = X₁ + ⋯ + X_n is a sum of n i.i.d. random variables each with mean μ = E[Xᵢ] = 500. Therefore E[S|N = n] = n × 500, or as a random variable, E[S|N] = 500N.
E[S|N] = 500N
3
Step 3 — Apply the Law of Total ExpectationE[S] = E[E[S|N]] = E[500N] = 500 × E[N] = 500 × 10 = 5,000.
E[S] = 5,000
4
Step 4 — Compute Var(S|N)Given N = n, the sum S has variance n × Var(Xᵢ) = n × 40,000 (by independence of the Xᵢ). As a random variable: Var(S|N) = 40,000 × N.
Var(S|N) = 40,000N
5
Step 5 — Apply the Law of Total Variance (Eve's Law)Var(S) = E[Var(S|N)] + Var(E[S|N]). The first term: E[40,000N] = 40,000 × E[N] = 40,000 × 10 = 400,000. The second term: Var(500N) = 500² × Var(N) = 250,000 × 10 = 2,500,000. (We used the fact that for N ~ Poisson(λ), Var(N) = λ = 10.) Therefore Var(S) = 400,000 + 2,500,000 = 2,900,000.
Var(S) = 2,900,000
6
Step 6 — InterpretationThe within-group variance E[Var(S|N)] = 400,000 measures the variability due to randomness in individual claim sizes for a fixed number of claims. The between-group variance Var(E[S|N]) = 2,500,000 measures the variability arising from the uncertain number of claims. In this example, the uncertainty in N contributes over 86% of the total variance, highlighting that the random count dominates the overall risk.

Strengths, Limitations & Comparison with Direct Methods

Computing via conditioning is not the only way to find expectations and variances. Direct integration, moment-generating functions, and characteristic functions offer alternative paths. The table below compares conditioning with these direct approaches so that you can appreciate when conditioning shines and when other methods may be preferable.

Conditioning vs. direct methods for computing moments
CriterionConditioning ApproachDirect Integration / MGFs
Ease of setupOften only requires identifying E[X|Y] and Var(X|Y) for a well-known conditional distribution—no explicit joint density needed.Requires the full joint density or explicit MGF, which may be difficult to derive for compound or hierarchical models.
InterpretabilityNaturally decomposes variance into within-group and between-group components, providing deep insight into the sources of variability.Yields a single number; the decomposition is not automatically provided.
Higher momentsExtending to E[X³] or skewness via conditioning is possible but increasingly cumbersome with each additional moment.MGFs and characteristic functions handle all moments uniformly through differentiation.
Distributional resultsConditioning yields moments but not the full distribution of X (without further work).MGFs/CFs can identify the full distribution through uniqueness theorems.
Recursive problemsExcels: first-step analysis, gambler's ruin, and Markov chain expectations reduce to elegant linear systems.Direct methods struggle with recursive or sequential structure.
🎯 WHEN TO CONDITION
Conditioning is your go-to tool whenever the problem exhibits a natural hierarchical or sequential structure—when X's distribution is determined by some intermediate random quantity Y. If no such structure exists and you have the joint density in closed form, direct integration or MGFs may be more efficient. In practice, many real-world problems (insurance, queuing, Bayesian models) are inherently hierarchical, making conditioning the dominant approach in applied probability.

Connection to Advanced Theory

The conditioning identities we have explored are special cases of much deeper results in measure-theoretic probability. In the general setting, conditional expectation E[X|𝒢] is defined as a 𝒢-measurable random variable satisfying ∫_A E[X|𝒢] dP = ∫_A X dP for all A ∈ 𝒢. This abstract definition, due to Kolmogorov and refined by Doob, generalizes our formulas from conditioning on a random variable Y to conditioning on an entire σ-algebra 𝒢, enabling applications in filtration-based frameworks such as martingale theory and stochastic calculus.

From conditioning basics to advanced probability and statistics
Concept in This LessonGeneralizationApplication Domain
E[E[X|Y]] = E[X]Tower property: E[E[X|𝒢]|ℋ] = E[X|ℋ] for ℋ ⊆ 𝒢Martingale convergence, Doob decomposition
Var(X) = E[Var(X|Y)] + Var(E[X|Y])ANOVA decomposition into within/between components for multiple nested factorsHierarchical Bayesian models, mixed-effects models
Conditioning on N in random sumsWald's identities: E[S_N] = E[N]·E[X₁] for stopping times NSequential analysis, renewal theory
E[X|Y] improves estimation of E[X]Rao–Blackwell theorem: E[T|S] has ≤ variance than TSufficient statistics, UMVUE construction

The Rao–Blackwell theorem deserves special emphasis: it states that if T is an unbiased estimator of θ and S is a sufficient statistic, then T* = E[T|S] is also unbiased and satisfies Var(T*) ≤ Var(T). The proof is a direct application of Eve's law. Since Var(T) = E[Var(T|S)] + Var(E[T|S]) = E[Var(T|S)] + Var(T*), and E[Var(T|S)] ≥ 0, we conclude Var(T*) ≤ Var(T). This beautiful result shows that conditioning on more information never increases mean squared error—a principle that pervades modern statistics.

Practice Problems

PROBLEM 1CONCEPTUAL
Explain in your own words why E[X|Y] is a random variable rather than a fixed number. What is the source of its randomness? Then state, without proof, how the law of total expectation uses this fact to recover E[X].
PROBLEM 2BASIC CALCULATION
Let X|P ~ Binomial(20, P) where P ~ Uniform(0, 1). Use the law of total expectation to find E[X], and then apply Eve's law to find Var(X).
PROBLEM 3INTERMEDIATE
A fair coin is flipped, and the outcome determines a distribution: if Heads, X ~ Exponential(1); if Tails, X ~ Exponential(1/3). Find E[X] and Var(X) using conditioning on the coin outcome Y ∈ {H, T}.
PROBLEM 4APPLIED
A call center receives N calls per hour, where N ~ Poisson(λ = 8). Each call lasts a random duration Dᵢ (in minutes), independently drawn from a distribution with E[Dᵢ] = 6 and Var(Dᵢ) = 4. The total agent-time used per hour is T = D₁ + D₂ + ⋯ + D_N. Find E[T] and Var(T). If the center has 60 agent-minutes available, find the probability that demand exceeds capacity using a normal approximation.
PROBLEM 5CRITICAL THINKING
Prove that for any random variable X and any random variable Y (with finite second moments), conditioning on Y can never increase the expected squared error of prediction. Specifically, show that E[(X − E[X])²] ≥ E[(X − E[X|Y])²], and interpret the difference between these two quantities using the law of total variance.

Summary — Computing via Conditioning

Computing via conditioning is a cornerstone technique in probability that leverages the law of total expectation E[X] = E[E[X|Y]] and the law of total variance Var(X) = E[Var(X|Y)] + Var(E[X|Y]) to decompose intractable moment calculations into manageable conditional pieces. The central insight is that conditional expectation E[X|Y] is itself a random variable—a function of Y—whose own moments can be computed by averaging over the distribution of Y. The variance decomposition separates total variability into a within-group component E[Var(X|Y)] and a between-group component Var(E[X|Y]), providing both computational efficiency and deep interpretive insight.

The art of the method lies in choosing the right conditioning variable Y so that the conditional distribution of X given Y is a well-known, tractable family. Common strategies include conditioning on mixture parameters in hierarchical models, random counts in compound distributions, and first-step outcomes in sequential and Markov chain problems. These identities generalize to the measure-theoretic tower property and underpin advanced results including the Rao–Blackwell theorem, ANOVA decompositions, and variance reduction in Monte Carlo methods.

Varsity Tutors • Statistics Graduate Level • Computing via Conditioning — Compute expectations and variances using conditioning