Tutorials › Stochastic Processes › Conditional Expectation from Conditional Densities

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

Conditional Expectation from Conditional Densities

Use a conditional density to calculate conditional expectations, identify the resulting function of the conditioning variable, and check when the formula applies.

Intermediate 9 min read

What You'll Learn

  • Derive a conditional density from a joint density and its marginal
  • Calculate conditional expectations by integrating against that density
  • State the integrability and almost-everywhere conditions behind the formula
  • Work out conditional expectation functions in three bivariate examples
  • Recognize and correct a common joint-density normalization error

From a Conditional Density to a Conditional Expectation

When a joint density is known, it can answer more than questions about probabilities. It can also describe the distribution of one variable after the value of another is observed. Integrating a function against that conditional density gives the conditional expectation; as the observed value varies, the answer is a function of that value.

Let \((\Omega,\mathcal{F},\mathbb{P})\) be a probability space, and let \(X\) and \(Y\) be real-valued random variables with joint density \(f_{X,Y}(x,y)\) with respect to two-dimensional Lebesgue measure. Their marginal density for \(X\) is \[ f_X(x)=\int_{\mathbb{R}} f_{X,Y}(x,y)\,dy. \] At values \(x\) where \(f_X(x)>0\), the conditional density of \(Y\) given \(X=x\) is obtained by dividing the joint density by that marginal density.

Definition: For \(x\) with \(f_X(x)>0\), define \[ f_{Y\mid X}(y\mid x)=\frac{f_{X,Y}(x,y)}{f_X(x)}. \] This density is specified only up to choices on sets of \(x\)-values having probability zero under \(X\). Where \(f_X(x)=0\), its value can be assigned arbitrarily without affecting conditional expectations as random variables.

The division matters: a joint density describes both the likelihood of seeing \(X\) near \(x\) and the distribution of \(Y\) there. Dividing by \(f_X(x)\) removes the first factor and leaves a density over possible \(Y\)-values, for almost every observed \(x\).

Theorem (Conditional expectation from a conditional density): Suppose \(f_{X,Y}\) is a joint density and \(g:\mathbb{R}\to\mathbb{R}\) is measurable with \(\mathbb{E}|g(Y)|<\infty\). Then, for \(f_X(x)>0\) and almost every such \(x\), \[ h(x)=\int_{\mathbb{R}}g(y)f_{Y\mid X}(y\mid x)\,dy \] is finite, and \[ \mathbb{E}[g(Y)\mid \sigma(X)]=h(X)\quad\text{almost surely}. \] Here \(\sigma(X)\) is the information generated by \(X\). More generally, if \(g(x,y)\) is measurable and \(\mathbb{E}|g(X,Y)|<\infty\), then a version of \(\mathbb{E}[g(X,Y)\mid\sigma(X)]\) is \(h(X)\), where \[ h(x)=\int_{\mathbb{R}}g(x,y)f_{Y\mid X}(y\mid x)\,dy \] for almost every \(x\) with \(f_X(x)>0\).

The theorem asserts equality almost surely, not equality at every numerical value \(x\). A conditional expectation is defined by its averages over events determined by \(X\); changing the function at values \(x\) that \(X\) takes with probability zero does not change that random variable.

Proof. First consider \(g(Y)\). Since \(\mathbb{E}|g(Y)|<\infty\), integration of \(|g(y)|f_{X,Y}(x,y)\) over \((x,y)\) is finite. Tonelli's theorem applied to this nonnegative integrand implies that for almost every \(x\) with \(f_X(x)>0\), the integral of \(|g(y)|f_{Y\mid X}(y\mid x)\) is finite. Thus \(h(x)\) is finite there. For any Borel set \(B\subseteq\mathbb{R}\), the joint-density formula and Fubini's theorem give \[ \begin{aligned} \mathbb{E}\big[\mathbf{1}_{\{X\in B\}}g(Y)\big] &=\int_B\int_{\mathbb{R}}g(y)f_{X,Y}(x,y)\,dy\,dx\\ &=\int_B h(x)f_X(x)\,dx\\ &=\mathbb{E}\big[\mathbf{1}_{\{X\in B\}}h(X)\big]. \end{aligned} \] The middle equality uses \(f_{X,Y}(x,y)=f_X(x)f_{Y\mid X}(y\mid x)\) wherever \(f_X(x)>0\); the set where \(f_X(x)=0\) contributes zero to the integral. The events \(\{X\in B\}\) generate \(\sigma(X)\). The displayed identity for every such \(B\), together with the integrability just established, is the defining property of conditional expectation, so \(h(X)\) is a version of \(\mathbb{E}[g(Y)\mid\sigma(X)]\). For \(g(X,Y)\), the same calculation replaces \(g(y)\) by \(g(x,y)\); the assumed integrability justifies Fubini and yields the stated formula. \(\square\)

One preliminary check is useful in every application: the proposed conditional density must integrate to one in \(y\), for almost every \(x\) under the marginal distribution of \(X\). This follows directly from its definition.

Result (Normalization of the conditional density): For almost every \(x\) with \(f_X(x)>0\), \[ \int_{\mathbb{R}}f_{Y\mid X}(y\mid x)\,dy=1. \]

Proof. For each \(x\) with \(f_X(x)>0\) for which the marginal integral is defined, \[ \int_{\mathbb{R}}f_{Y\mid X}(y\mid x)\,dy =\frac{1}{f_X(x)}\int_{\mathbb{R}}f_{X,Y}(x,y)\,dy =\frac{f_X(x)}{f_X(x)}=1. \] The marginal density identity holds almost everywhere, which gives the asserted qualification. \(\square\)

Worked Calculations

Worked Example: A Uniform Distribution on a Triangle

Suppose \((X,Y)\) has joint density \(f_{X,Y}(x,y)=2\) when \(0<y<x<1\), and zero elsewhere. Find \(\mathbb{E}[Y\mid\sigma(X)]\) and \(\mathbb{E}[Y^2\mid\sigma(X)]\).

First find the marginal density. For \(0<x<1\), the allowed values of \(y\) satisfy \(0<y<x\), so \[ f_X(x)=\int_0^x 2\,dy=2x. \] Outside this interval \(f_X(x)=0\). The marginal is normalized since \(\int_0^1 2x\,dx=1\). For \(0<x<1\), the conditional density is therefore \[ f_{Y\mid X}(y\mid x)=\frac{2}{2x}=\frac1x,\qquad 0<y<x. \] Its integral is \(\int_0^x (1/x)\,dy=1\).

For the conditional mean, integrate \(y\) against this density: \[ \mathbb{E}[Y\mid X=x] =\int_0^x y\frac1x\,dy =\frac1x\left[\frac{y^2}{2}\right]_0^x =\frac{x}{2}. \] Thus \(\mathbb{E}[Y\mid\sigma(X)]=X/2\) almost surely. For the second moment, \[ \mathbb{E}[Y^2\mid X=x] =\int_0^x y^2\frac1x\,dy =\frac1x\left[\frac{y^3}{3}\right]_0^x =\frac{x^2}{3}. \] So the corresponding conditional expectation is \(X^2/3\) almost surely.

Check: At \(x=\tfrac12\), the conditional density is \(2\) on \(0<y<\tfrac12\). Its mean is \(2\int_0^{1/2}y\,dy=2\cdot\tfrac18=\tfrac14=x/2\), and its second moment is \(2\int_0^{1/2}y^2\,dy=2\cdot\tfrac1{24}=\tfrac1{12}=x^2/3\).

Worked Example: An Exponential Conditional Density

Suppose the joint density is \[ f_{X,Y}(x,y)=(1+x)e^{-(1+x)y},\qquad 0<x<1,\quad y>0, \] and is zero elsewhere. Find \(\mathbb{E}[Y\mid\sigma(X)]\).

For \(0<x<1\), integrate over \(y>0\): \[ f_X(x)=\int_0^\infty(1+x)e^{-(1+x)y}\,dy =\left[-e^{-(1+x)y}\right]_{0}^{\infty}=1. \] The marginal integrates to \(\int_0^1 1\,dx=1\), and the conditional density is \[ f_{Y\mid X}(y\mid x)=(1+x)e^{-(1+x)y},\qquad y>0. \] For \(\lambda=1+x>0\), integration by parts gives \[ \int_0^\infty y\lambda e^{-\lambda y}\,dy =\left[-ye^{-\lambda y}\right]_0^\infty+\int_0^\infty e^{-\lambda y}\,dy =0+\frac1\lambda. \] Consequently, \[ \mathbb{E}[Y\mid X=x]=\frac1{1+x},\qquad 0<x<1, \] and \(\mathbb{E}[Y\mid\sigma(X)]=1/(1+X)\) almost surely.

Check: At \(x=\tfrac12\), the rate is \(1+\tfrac12=\tfrac32\), so the conditional mean is \(1/(\tfrac32)=\tfrac23\). The conditional density \(\tfrac32e^{-3y/2}\) integrates to \(1\), and the integration-by-parts calculation gives its mean \(2/3\).

Worked Example: Dependence Changes the Conditional Mean

On the unit square \(0<x<1,\ 0<y<1\), let \[ f_{X,Y}(x,y)=1+(2x-1)(2y-1), \] and let the density be zero elsewhere. Find \(\mathbb{E}[Y\mid\sigma(X)]\).

Both factors \(2x-1\) and \(2y-1\) lie between \(-1\) and \(1\), so their product is at least \(-1\); hence the density is nonnegative. Its marginal in \(x\) is \[ f_X(x)=\int_0^1\big[1+(2x-1)(2y-1)\big]\,dy =1+(2x-1)\left[y^2-y\right]_0^1=1. \] The marginal integrates to one over \(0<x<1\), and the conditional density equals the joint density on the square. Its integral in \(y\) is the same marginal calculation, so it is normalized.

Now calculate its conditional mean: \[ \begin{aligned} \mathbb{E}[Y\mid X=x] &=\int_0^1 y\big[1+(2x-1)(2y-1)\big]\,dy\\ &=\frac12+(2x-1)\left(\frac23-\frac12\right)\\ &=\frac12+\frac{2x-1}{6} =\frac{x+1}{3}. \end{aligned} \] Therefore \(\mathbb{E}[Y\mid\sigma(X)]=(X+1)/3\) almost surely. In particular, the conditional mean varies with \(x\), despite both variables having values between zero and one.

Check: At \(x=\tfrac14\), the formula gives \((1+\tfrac14)/3=\tfrac5{12}\). Directly, the integral is \(\tfrac12+(-\tfrac12)(\tfrac16)=\tfrac12-\tfrac1{12}=\tfrac5{12}\).

What the Formula Does—and Does Not—Say

The conditional expectation is a function of the conditioning variable because the observed value \(X=x\) determines which conditional density to use. In the examples, integrating against that density produced \(x/2\), \(1/(1+x)\), and \((x+1)/3\). Once this function is evaluated at the random variable \(X\), it represents the conditional expectation as a random variable.

The condition \(\mathbb{E}|g(Y)|<\infty\) ensures the conditional expectation is finite almost surely. For a nonnegative \(g\), the same integral formula is valid as an extended nonnegative conditional expectation, which may be infinite on a set of positive probability. Values of \(x\) outside the support of \(X\), and exceptional values within the support where a density formula is not specified, do not determine the conditional expectation as a random variable. A formula there can be chosen as a version, but it is not uniquely determined by conditioning.

Common mistake: forgetting to divide by the marginal. In the triangular example, a wrong calculation might use \[ \int_0^x y f_{X,Y}(x,y)\,dy =\int_0^x 2y\,dy=x^2 \] as the conditional mean. This is not a conditional mean: it is the joint-density-weighted numerator. The correct calculation divides by \(f_X(x)=2x\), giving \(x^2/(2x)=x/2\) for \(0<x<1\). Equivalently, first form the conditional density \(2/(2x)=1/x\), then integrate \(y\) against it. The denominator is essential because the conditional density must integrate to one.

Check Your Understanding

For each question, write the marginal density first, then check that the conditional density integrates to one before calculating an expectation.

  1. For the triangular density in the first example, find \(\mathbb{E}[Y^3\mid\sigma(X)]\).
  2. If \(f_{Y\mid X}(y\mid x)=3y^2\) for \(0<y<1\), calculate \(\mathbb{E}[Y\mid X=x]\).
  3. In the exponential example, what is the conditional mean at \(x=\tfrac13\)? Show the rate substitution.
  4. For the unit-square density in the third example, calculate the conditional mean at \(x=\tfrac34\) by both the displayed formula and direct integration.
  5. Why can a conditional-density formula be changed at \(x\)-values where \(f_X(x)=0\) without changing the conditional expectation almost surely?