01 / 21

Computing via
Conditioning

Master the art of computing expectations and variances by conditioning on auxiliary random variables: the tower property and the Eve's law decomposition.

Statistics

What Is Conditioning?

In probability, conditioning means restricting our probability space to a particular event or value of a random variable. When we condition on \(Y\), we treat \(Y\) as if it were known, compute a quantity as a function of \(Y\), and then average over all possible values of \(Y\).

\(E[X \mid Y]\) as a Random Variable

When we write \(E[X \mid Y]\), we do not get a single number: we get a function of \(Y\). For each possible value \(y\) of \(Y\), we have the number \(E[X \mid Y = y]\). Since \(Y\) is random, \(E[X \mid Y] = g(Y)\) is itself a random variable.

\(E[X \mid Y = y]\)
A number: the expected value of \(X\) given \(Y\) takes the specific value \(y\).
\(E[X \mid Y]\)
A random variable: replace \(y\) with the random variable \(Y\), yielding \(g(Y)\).

Why Conditioning Matters

Many real-world problems involve mixture models, random sample sizes, or multi-stage experiments where direct computation of \(E[X]\) or \(\text{Var}(X)\) is intractable. Conditioning provides a systematic decomposition strategy.

1
Simplification: Conditional distributions are often simpler than marginal distributions.
2
Modularity: Complex models decompose into stages, each with its own conditional law.
3
Generality: Works for discrete and continuous variables, univariate and multivariate settings.

The Tower Property

Discrete form: If \(Y\) takes values \(y_1, y_2, \ldots\), then $$ E[X] = \sum_{i} E[X \mid Y = y_i]\, P(Y = y_i). $$ Continuous form: If \(Y\) has density \(f_Y\), then $$ E[X] = \int_{-\infty}^{\infty} E[X \mid Y = y]\, f_Y(y)\, dy. $$

Eve's Law: Total Variance

\(E[\text{Var}(X \mid Y)]\)
Within-group variance: the average variability of \(X\) within each level of \(Y\).
\(\text{Var}(E[X \mid Y])\)
Between-group variance: how much the conditional mean itself varies across levels of \(Y\).

Variance Decomposition Diagram

\(\text{Var}(X)\)
=
\(E[\text{Var}(X \mid Y)]\)
+
\(\text{Var}(E[X \mid Y])\)
Within-group variability Between-group variability Example: Three Groups

Adam's vs Eve's Law

Adam's Law Eve's Law
Computes \(E[X]\) \(\text{Var}(X)\)
Formula \(E[E[X \mid Y]]\) \(E[\text{Var}(X \mid Y)] + \text{Var}(E[X \mid Y])\)
Number of terms 1 2
Mnemonic Iterated expectation EVVE: E of Var + Var of E
Key insight Average the conditional means Partition total variability

How to Apply Conditioning

1
Identify the target: Do you need \(E[X]\) or \(\text{Var}(X)\)?
2
Choose a conditioning variable \(Y\): Pick a variable that, once known, makes the conditional distribution of \(X\) simple (e.g., a known named distribution).
3
Compute the inner quantities: Find \(E[X \mid Y]\) and (for variance) \(\text{Var}(X \mid Y)\) as functions of \(Y\).
4
Take the outer operations: Apply Adam's Law or both terms of Eve's Law to get the final answer.

Example 1: Random Sum

Let \(N \sim \text{Pois}(\lambda)\) and let \(X_1, X_2, \ldots\) be i.i.d. with mean \(\mu\) and variance \(\sigma^2\), independent of \(N\). Define \(T = \sum_{i=1}^{N} X_i\). Find \(E[T]\).

Example 1: Variance of \(T\)

We continue with \(T = \sum_{i=1}^{N} X_i\) where \(N \sim \text{Pois}(\lambda)\). Find \(\text{Var}(T)\) using Eve's Law.

Example 2: Mixture of Normals

Let \(Y \sim N(0, 1)\), and given \(Y = y\), let \(X \mid Y \sim N(y, 1)\). Find \(E[X]\) and \(\text{Var}(X)\).

Example 3: First-Step Analysis

A gambler flips a fair coin until the first Head. Let \(X\) be the number of flips. Use conditioning on the first flip to find \(E[X]\).

Choosing \(Y\) Wisely

The power of conditioning hinges on choosing the right variable to condition on. A good choice makes the conditional distribution of \(X\) a known, named distribution.

Random sums
Condition on the random count \(N\). Given \(N\), the sum is a fixed sum of i.i.d. terms.
Hierarchical models
Condition on the latent parameter. E.g., \(X \mid \Theta \sim \text{Bin}(n, \Theta)\).
Sequential processes
Condition on the first step. This yields recursive equations (first-step analysis).

Common Mistakes

✕ Confusing number and RV
Writing \(E[X \mid Y = y]\) when you mean \(E[X \mid Y]\). The first is a number; the second is a random variable.
✕ Forgetting a term in Eve's Law
Using only \(E[\text{Var}(X \mid Y)]\) and forgetting the \(\text{Var}(E[X \mid Y])\) term, or vice versa.
✕ Wrong outer operation
Taking \(\text{Var}[\text{Var}(X \mid Y)]\) instead of \(E[\text{Var}(X \mid Y)]\). Remember: EVVE pattern.

Summary of Key Formulas

Formula Statement Mnemonic
Total Expectation \(E[X] = E[E[X \mid Y]]\) Adam's Law
Total Variance \(\text{Var}(X) = E[\text{Var}(X \mid Y)] + \text{Var}(E[X \mid Y])\) Eve's Law (EVVE)
Random Sum Mean \(E\![\sum_{i=1}^N X_i] = E[N] \cdot E[X_1]\) Wald's identity
Random Sum Var \(E[N]\sigma^2 + \mu^2 \text{Var}(N)\) EVVE on random sum

Question 1 of 5

By the Law of Total Expectation, \(E[X] = E\![E[X \mid Y]]\). What is the nature of \(E[X \mid Y]\)?

Question 2 of 5

Let \(N \sim \text{Pois}(5)\), and \(X_1, X_2, \ldots\) i.i.d. with \(E[X_i] = 3\), independent of \(N\). What is \(E\![\sum_{i=1}^N X_i]\)?

Question 3 of 5

In Eve's Law, the term \(\text{Var}\!(E[X \mid Y])\) captures which component of total variability?

Question 4 of 5

Let \(Y \sim N(0,1)\) and \(X \mid Y \sim N(Y, 4)\). What is \(\text{Var}(X)\)?

Question 5 of 5

A fair coin is flipped repeatedly. Let \(X\) be the number of flips to get the first Head. Conditioning on the first flip outcome, which equation correctly determines \(E[X]\)?