Tutorials › Stochastic Processes › The Conditional Variance Formula

Random Variables, Expectation and Conditional Expectation · Tutorial 23 of 994

The Conditional Variance Formula

Learn to define conditional variance precisely, derive its two equivalent forms, and calculate it from discrete or continuous conditional distributions.

Intermediate 10 min read

What You'll Learn

  • Define conditional variance for a square-integrable random variable and a sigma-algebra.
  • Derive its centered-square and conditional-second-moment formulas.
  • Calculate conditional variance on positive-probability atoms of a discrete variable.
  • Compute conditional variances from conditional densities.
  • Check when conditional variance is zero and identify a common incorrect calculation.

Variance After Conditioning

Once information is available, the uncertainty in a random variable can change. For example, the spread of a measurement may differ across groups, or the spread of a waiting time may depend on a known rate. Conditional variance describes that remaining spread while keeping the conditioning information fixed. Unlike an ordinary variance, it is generally a random variable: its value can depend on what is learned.

Work on a probability space \((\Omega,\mathcal{F},\mathbb{P})\). Let \(X\) be a real-valued random variable with \(\mathbb{E}[X^2]<\infty\), and let \(\mathcal{G}\subseteq\mathcal{F}\) be a sigma-algebra representing the available information. Write \(m=\mathbb{E}[X\mid\mathcal{G}]\). Conditional expectations are defined up to almost-sure equality; all conditional-variance identities below have the same convention.

Definition: The conditional variance of \(X\) given \(\mathcal{G}\) is \(\operatorname{Var}(X\mid\mathcal{G})=\mathbb{E}[(X-\mathbb{E}[X\mid\mathcal{G}])^2\mid\mathcal{G}]\). It measures the squared deviation from the conditional mean, averaged while holding the information in \(\mathcal{G}\) fixed.

The square-integrability assumption ensures that the quantities in this definition are finite almost surely. The definition centers \(X\) at its conditional mean, not at its unconditional mean. This distinction is essential: conditioning changes the reference point around which the remaining variation is measured.

The Two Equivalent Forms

Theorem (Conditional variance identity): If \(\mathbb{E}[X^2]<\infty\), then for any sigma-algebra \(\mathcal{G}\subseteq\mathcal{F}\), \(\operatorname{Var}(X\mid\mathcal{G})=\mathbb{E}[X^2\mid\mathcal{G}]-(\mathbb{E}[X\mid\mathcal{G}])^2\) almost surely. In particular, conditional variance is nonnegative almost surely.

Proof. Set \(m=\mathbb{E}[X\mid\mathcal{G}]\). We first check that \(m\) is square-integrable so the algebra below is legitimate. For each positive integer \(r\), the random variable \(H_r=m\mathbf{1}_{\{|m|\le r\}}\) is bounded and \(\mathcal{G}\)-measurable. The defining integral property of conditional expectation gives \(\mathbb{E}[mH_r]=\mathbb{E}[XH_r]\). Therefore, writing \(a_r=(\mathbb{E}[m^2\mathbf{1}_{\{|m|\le r\}}])^{1/2}\), the Cauchy–Schwarz inequality yields \(a_r^2\le(\mathbb{E}[X^2])^{1/2}a_r\). If \(a_r=0\) this already gives \(a_r\le(\mathbb{E}[X^2])^{1/2}\); if \(a_r>0\), division by \(a_r\) gives the same bound. As \(r\) increases, monotone convergence shows \(\mathbb{E}[m^2]\le\mathbb{E}[X^2]<\infty\). Now expand the square and use linearity and the rule that a \(\mathcal{G}\)-measurable factor can be taken outside conditional expectation: \(\mathbb{E}[(X-m)^2\mid\mathcal{G}]=\mathbb{E}[X^2\mid\mathcal{G}]-2m\mathbb{E}[X\mid\mathcal{G}]+\mathbb{E}[m^2\mid\mathcal{G}]=\mathbb{E}[X^2\mid\mathcal{G}]-m^2\). The left side is a conditional expectation of a nonnegative random variable, so it is nonnegative almost surely. \(\square\)

The second form is often quicker to calculate: find the conditional first and second moments, then subtract the square of the first. The centered-square definition is often better for interpretation and for direct verification. Both forms describe the same \(\mathcal{G}\)-measurable random variable.

Proposition: Under the theorem’s square-integrability assumption, \(\operatorname{Var}(X\mid\mathcal{G})=0\) almost surely if and only if \(X=\mathbb{E}[X\mid\mathcal{G}]\) almost surely.

Proof. Let \(V=\operatorname{Var}(X\mid\mathcal{G})\). By the tower property, \(\mathbb{E}[V]=\mathbb{E}[(X-m)^2]\), where \(m=\mathbb{E}[X\mid\mathcal{G}]\). If \(V=0\) almost surely, then \(\mathbb{E}[(X-m)^2]=0\); a nonnegative random variable with expectation zero is zero almost surely, so \(X=m\) almost surely. Conversely, if \(X=m\) almost surely, then \((X-m)^2=0\) almost surely, and its conditional expectation is zero almost surely. \(\square\)

Conditioning on a Discrete Variable

Let \(Y\) be a discrete random variable and take \(\mathcal{G}=\sigma(Y)\), the information generated by \(Y\). For a value \(y\) with \(\mathbb{P}(Y=y)>0\), conditional moments are computed from the conditional distribution of \(X\) given \(Y=y\). In particular, \(\operatorname{Var}(X\mid Y=y)=\sum_x (x-\mathbb{E}[X\mid Y=y])^2\mathbb{P}(X=x\mid Y=y)\), when \(X\) is discrete. Equivalently, it is the conditional second moment minus the squared conditional mean. Values \(y\) with probability zero do not define an event-conditioned expectation by the ratio formula; conditional quantities there may be assigned arbitrarily without changing the almost-sure identity.

Worked Example: Two Conditional Distributions

Let \(Y\) take values \(0\) and \(1\), each with probability \(\tfrac12\). Given \(Y=0\), let \(X\) equal \(0\) or \(2\), each with probability \(\tfrac12\). Given \(Y=1\), let \(X\) equal \(1,3,5\) with probabilities \(\tfrac14,\tfrac12,\tfrac14\), respectively. Each conditional probability list sums to \(1\). Find the conditional mean and variance at both values of \(Y\).

For \(Y=0\), the conditional mean is \(0\cdot\tfrac12+2\cdot\tfrac12=1\), and the conditional second moment is \(0^2\cdot\tfrac12+2^2\cdot\tfrac12=2\). Thus the conditional-variance identity gives \(2-1^2=1\). Directly, the centered-square calculation is \((0-1)^2\cdot\tfrac12+(2-1)^2\cdot\tfrac12=\tfrac12+\tfrac12=1\).

For \(Y=1\), the conditional mean is \(1\cdot\tfrac14+3\cdot\tfrac12+5\cdot\tfrac14=\tfrac14+\tfrac32+\tfrac54=3\). The second moment is \(1^2\cdot\tfrac14+3^2\cdot\tfrac12+5^2\cdot\tfrac14=\tfrac14+\tfrac92+\tfrac{25}4=11\). Hence the conditional variance is \(11-3^2=2\). Directly, the centered-square calculation is \((1-3)^2\cdot\tfrac14+(3-3)^2\cdot\tfrac12+(5-3)^2\cdot\tfrac14=1+0+1=2\).

Check: The conditional variance is \(1\) when \(Y=0\) and \(2\) when \(Y=1\). Substitution into the second-moment identity gives \(2-1=1\) and \(11-9=2\), agreeing with both centered-square calculations.

Conditioning on a Density

When \(Y\) is continuous, the event \(Y=y\) usually has probability zero, so conditional distributions are described by conditional densities rather than by dividing by \(\mathbb{P}(Y=y)\). If \(f_{X\mid Y}(x\mid y)\) is a conditional density, then for almost every relevant \(y\), \(\mathbb{E}[X\mid Y=y]=\int x f_{X\mid Y}(x\mid y)\,dx\) and \(\mathbb{E}[X^2\mid Y=y]=\int x^2 f_{X\mid Y}(x\mid y)\,dx\). The conditional variance is the second integral minus the square of the first. Conditional densities, like conditional expectations, are only specified up to changes on a set of \(y\)-values with probability zero.

Worked Example: A Uniform Conditional Density

Suppose \(Y\) is uniform on \((0,2)\), and given \(Y=y\), \(X\) is uniform on \((0,y)\) for \(y>0\). The conditional density is \(f_{X\mid Y}(x\mid y)=1/y\) for \(0<x<y\), and zero otherwise. Its integral over \((0,y)\) is \(\int_0^y (1/y)\,dx=1\).

For \(y>0\), the conditional mean is \(\int_0^y x(1/y)\,dx=(1/y)[x^2/2]_0^y=y/2\). The conditional second moment is \(\int_0^y x^2(1/y)\,dx=(1/y)[x^3/3]_0^y=y^2/3\). Thus \(\operatorname{Var}(X\mid Y=y)=y^2/3-(y/2)^2=y^2/3-y^2/4=y^2/12\).

Check using the centered square: \(\int_0^y (x-y/2)^2(1/y)\,dx=(1/y)[x^3/3-yx^2/2+y^2x/4]_0^y\). At the upper endpoint, the bracket is \(y^3/3-y^3/2+y^3/4=y^3/12\); at zero it is \(0\). Dividing by \(y\) gives \(y^2/12\), as before. The two calculations agree for every \(y>0\), which is the range relevant to the distribution of \(Y\).

Worked Example: Exponential Conditional Densities

Let \(Y\) take values \(1\) and \(2\), each with probability \(\tfrac12\). Given \(Y=y\), let \(X\) have density \(f_{X\mid Y}(x\mid y)=y e^{-yx}\) for \(x\ge0\). For both possible values of \(y\), this is a density because \(\int_0^\infty y e^{-yx}\,dx=[-e^{-yx}]_0^\infty=1\). Calculate the conditional variances.

For \(y>0\), integration by parts gives \(\int_0^\infty x y e^{-yx}\,dx=1/y\): use \(u=x\), \(dv=y e^{-yx}dx\), so \(v=-e^{-yx}\); the boundary term \([-x e^{-yx}]_0^\infty\) is zero, and the remaining integral is \(\int_0^\infty e^{-yx}dx=1/y\). A second integration by parts gives \(\int_0^\infty x^2 y e^{-yx}\,dx=(2/y)\int_0^\infty x y e^{-yx}\,dx=2/y^2\); its boundary term \([-x^2 e^{-yx}]_0^\infty\) is also zero.

At \(Y=1\), these moments are \(1\) and \(2\), so the conditional variance is \(2-1^2=1\). At \(Y=2\), they are \(\tfrac12\) and \(\tfrac12\), so the conditional variance is \(\tfrac12-(\tfrac12)^2=\tfrac14\). The direct centered-square check uses the same moments: \(\mathbb{E}[(X-1)^2\mid Y=1]=2-2(1)(1)+1=1\), and \(\mathbb{E}[(X-\tfrac12)^2\mid Y=2]=\tfrac12-2(\tfrac12)(\tfrac12)+\tfrac14=\tfrac14\).

Check: The conditional variance takes the values \(1\) and \(\tfrac14\) at \(Y=1\) and \(Y=2\), respectively. Both values agree with the centered-square calculation and are nonnegative.

Common Error and Practical Checks

A frequent mistake is to subtract the square of the unconditional mean rather than the square of the conditional mean. In the first example, the unconditional mean is \(\mathbb{E}[X]=\tfrac12(1)+\tfrac12(3)=2\). For \(Y=0\), the incorrect calculation would be \(\mathbb{E}[X^2\mid Y=0]-(\mathbb{E}[X])^2=2-2^2=-2\). This cannot be a variance, and it is not the conditional variance. The correct subtraction uses \(\mathbb{E}[X\mid Y=0]=1\), giving \(2-1^2=1\).

For a new calculation, first identify the information being conditioned on and the corresponding conditional distribution. Then compute its conditional mean and second moment, and subtract the square of that conditional mean. If possible, independently compute the average squared deviation from the conditional mean. A negative result signals an arithmetic error or a mismatch between the conditional and unconditional quantities. Finally, remember that a conditional variance is generally a random variable—such as \(Y^2/12\) in the uniform example—not a single constant.

Check Your Understanding

Use the conditional-mean and conditional-second-moment formulas, and check your results by centering at the conditional mean.

  1. Given \(Y=0\), suppose \(X\) is \(2\) or \(4\), each with probability \(\tfrac12\). Find \(\mathbb{E}[X\mid Y=0]\) and \(\operatorname{Var}(X\mid Y=0)\).
  2. If \(X\mid Y=y\) is uniform on \((0,2y)\) for \(y>0\), compute its conditional mean and variance.
  3. Why does the event-ratio formula for conditioning on \(Y=y\) require \(\mathbb{P}(Y=y)>0\), and what replaces it for a continuous \(Y\)?
  4. State the square-integrability assumption used for the conditional variance identity and explain why the conditional variance is nonnegative almost surely.
  5. In the exponential example, identify the incorrect result produced by subtracting \((\mathbb{E}[X])^2\) instead of \((\mathbb{E}[X\mid Y])^2\) at \(Y=1\).