Tutorials › Statistical Theory I - Probability and Distribution Theory › Deriving Conditional Densities from Joint Densities

Conditional Expectation · Tutorial 327 of 994

Deriving Conditional Densities from Joint Densities

Derive conditional densities by integrating out a variable, dividing by the relevant marginal density, and then use the resulting density to calculate conditional expectations.

Intermediate 10 min read

What You'll Learn

  • Integrate a joint density over the appropriate coordinate to obtain a marginal density.
  • Derive a conditional density by dividing by the marginal where it is positive.
  • Identify the conditional support from the joint support.
  • Check that a proposed conditional density integrates to one.
  • Calculate conditional expectations by integrating against the conditional density.
  • Recognize why conditional densities are determined only almost everywhere under the conditioning variable’s distribution.

From a Joint Density to a Conditional Density

A joint density describes two continuous random variables together, but many questions concern one variable after the value of the other is known. The conditional density is the tool that makes this change of viewpoint precise. Its derivation has two essential steps: first integrate the joint density to find the marginal density of the conditioning variable, then divide by that marginal on the part of the support where it is positive.

The division is not a purely algebraic operation. The support matters: for a fixed value of the conditioning variable, the possible values of the other variable may occupy only part of the real line. The resulting conditional density must integrate to one over those possible values.

Definition: Let \((X,Y)\) have joint density \(f_{X,Y}(x,y)\) with respect to two-dimensional Lebesgue measure. Its marginal densities are $$ f_X(x)=\int_{-\infty}^{\infty} f_{X,Y}(x,y)\,dy, \qquad f_Y(y)=\int_{-\infty}^{\infty} f_{X,Y}(x,y)\,dx. $$ For \(x\) such that \(0<f_X(x)<\infty\), a conditional density of \(Y\) given \(X=x\) is $$ f_{Y\mid X}(y\mid x)=\frac{f_{X,Y}(x,y)}{f_X(x)} $$ for Lebesgue-almost every \(y\). The formula is used on the section of the joint support at that \(x\), and the conditional density is zero off that section.

A joint density is nonnegative, measurable, and integrates to one over the plane. By Tonelli’s theorem, its marginal integrals are defined, and each marginal integrates to one. In particular, \(f_X(x)\) is finite for almost every \(x\); points where it is infinite form a set of Lebesgue measure zero. The conditional-density ratio is therefore used at \(x\) for which the marginal is finite and positive.

Where \(f_X(x)=0\), the ratio is undefined. Such values of \(x\) have probability zero under the distribution of \(X\), so a conditional density can be assigned arbitrarily there without changing the conditional law as a version defined almost everywhere. The same caution applies to exceptional \(x\) where the marginal is infinite. In ordinary calculations, we state the formula on the relevant support wherever the marginal is positive and finite.

Why the Ratio Gives a Conditional Density

The marginal \(f_X(x)\) measures the joint density accumulated over all possible \(y\)-values at a fixed \(x\). Dividing the joint density by this total rescales the density along that section so that it has total mass one. The next result checks this normalization directly.

Theorem: For every \(x\) with \(0<f_X(x)<\infty\), the ratio \(f_{X,Y}(x,y)/f_X(x)\) is nonnegative and integrates to one in \(y\), provided the marginal identity holds at that \(x\). Thus it is a probability density in \(y\).

Proof. The joint density is nonnegative, and \(f_X(x)>0\), so the ratio is nonnegative. By the definition of the marginal,

$$ \int_{-\infty}^{\infty}\frac{f_{X,Y}(x,y)}{f_X(x)}\,dy = \frac{1}{f_X(x)} \int_{-\infty}^{\infty}f_{X,Y}(x,y)\,dy = \frac{f_X(x)}{f_X(x)} =1. $$

If the joint density is zero outside a support region, the ratio is also zero outside the corresponding section of that region. Integrating over the whole real line or just that section therefore gives the same result. \(\square\)

The ratio also agrees with conditional probabilities. For a measurable set \(B\) of \(Y\)-values, integrating the conditional density over \(B\) gives the conditional probability of \(Y\in B\), at conditioning values where the formula applies. For a set \(A\) of \(X\)-values, the joint probability is recovered by integrating over \(x\):

$$ P(X\in A,\ Y\in B) = \int_A\int_B f_{X,Y}(x,y)\,dy\,dx = \int_A f_X(x) \left(\int_B f_{Y\mid X}(y\mid x)\,dy\right)dx. $$

This identity expresses the joint probability as a marginal density for \(X\) multiplied by the conditional probability of \(Y\in B\) given \(X=x\), then integrated over \(A\). It also explains why the conditional density is specified only up to changes on a set of \(x\)-values with probability zero.

Worked Examples

Worked Example: A Uniform Density on a Triangular Support

Suppose the joint density is \(f_{X,Y}(x,y)=2\) when \(0<y<x<1\), and zero otherwise. Find the marginal density of \(X\), the conditional density of \(Y\) given \(X=x\), and \(E[Y\mid X=x]\).

Step 1: Find the marginal of \(X\). For a fixed \(x\) between zero and one, the allowed \(y\)-values run from zero to \(x\). Therefore

$$ f_X(x)=\int_0^x 2\,dy=2x,\qquad 0<x<1. $$

The marginal is zero otherwise. It is normalized because \(\int_0^1 2x\,dx=1\).

Step 2: Divide on the section of the support. For \(0<x<1\) and \(0<y<x\),

$$ f_{Y\mid X}(y\mid x)=\frac{2}{2x}=\frac{1}{x}. $$

The conditional density is zero outside \(0<y<x\). Its integral is \(\int_0^x (1/x)\,dy=1\), as required.

Step 3: Calculate the conditional mean. Integrating \(y\) against this conditional density gives

$$ E[Y\mid X=x] = \int_0^x y\frac{1}{x}\,dy = \frac{1}{x}\left[\frac{y^2}{2}\right]_0^x = \frac{x}{2}. $$

The shrinking support is important: knowing that \(X=x\) restricts \(Y\) to values below \(x\), not to the entire interval from zero to one.

Worked Example: A Conditional Exponential Density on a Moving Support

Suppose \(f_{X,Y}(x,y)=e^{-y}\) on \(0<x<y<\infty\), and zero elsewhere. Find \(f_X(x)\), the conditional density of \(Y\) given \(X=x\), and its mean.

First check that the proposed joint density integrates to one:

$$ \int_0^\infty\int_0^y e^{-y}\,dx\,dy = \int_0^\infty y e^{-y}\,dy =1. $$

The last integral equals one by integration by parts. For fixed \(x>0\), the support requires \(y>x\), so

$$ f_X(x)=\int_x^\infty e^{-y}\,dy=e^{-x},\qquad x>0. $$

This marginal also integrates to one. Dividing gives

$$ f_{Y\mid X}(y\mid x)=e^{-(y-x)},\qquad y>x, $$

with density zero for \(y\leq x\). Its normalization follows from \(\int_x^\infty e^{-(y-x)}\,dy=1\), using the substitution \(u=y-x\). Its conditional mean is

$$ E[Y\mid X=x] = \int_x^\infty y e^{-(y-x)}\,dy = \int_0^\infty (x+u)e^{-u}\,du = x+1. $$

Here the support is an unbounded interval beginning at \(x\). Replacing it with \(y>0\) would discard the restriction in the joint density and produce the wrong conditional law.

Worked Example: A Smooth Density on a Rectangular Support

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

The joint density is normalized:

$$ \int_0^1\int_0^1 \frac45(1+xy)\,dy\,dx = \frac45\left(1+\frac14\right) =1. $$

Integrating over \(y\) gives the marginal

$$ f_X(x) = \int_0^1 \frac45(1+xy)\,dy = \frac45\left(1+\frac{x}{2}\right),\qquad 0<x<1. $$

Thus the conditional density is

$$ f_{Y\mid X}(y\mid x) = \frac{1+xy}{1+x/2},\qquad 0<y<1. $$

The denominator is positive throughout \(0<x<1\). Checking normalization explicitly,

$$ \int_0^1\frac{1+xy}{1+x/2}\,dy = \frac{1+x/2}{1+x/2} =1. $$

The conditional mean is

$$ E[Y\mid X=x] = \int_0^1 y\frac{1+xy}{1+x/2}\,dy = \frac{\frac12+\frac{x}{3}}{1+x/2}. $$

Unlike the first two examples, the support does not change with \(x\). The conditional density still depends on \(x\), because the joint density gives different relative weights to different \(y\)-values as \(x\) changes.

Conditional Expectations from Conditional Densities

Once the conditional density is known, conditional expectations are calculated by integrating against it. The formula is the continuous-density counterpart of averaging values according to their conditional probabilities.

Theorem: Suppose \(g\) is measurable and \(E[|g(Y)|]<\infty\). For \(f_X\)-almost every \(x\) with \(0<f_X(x)<\infty\), a version of the conditional expectation is $$ E[g(Y)\mid X=x] = \int_{-\infty}^{\infty}g(y)f_{Y\mid X}(y\mid x)\,dy = \frac{\int_{-\infty}^{\infty}g(y)f_{X,Y}(x,y)\,dy}{f_X(x)}. $$

Proof. Since \(E[|g(Y)|]<\infty\), the integral of \(|g(y)|f_{X,Y}(x,y)\) over the plane is finite. Fubini’s theorem therefore permits the iterated integrals below. For any measurable set \(A\) of \(X\)-values,

$$ \begin{aligned} E[g(Y)\mathbf{1}_{\{X\in A\}}] &=\int_A\int_{-\infty}^{\infty}g(y)f_{X,Y}(x,y)\,dy\,dx\\ &=\int_A f_X(x) \left[ \frac{\int_{-\infty}^{\infty}g(y)f_{X,Y}(x,y)\,dy}{f_X(x)} \right]dx. \end{aligned} $$

The bracketed function is measurable where defined, and can be assigned any finite value on the set where \(f_X(x)=0\). The displayed identity for every measurable \(A\) is the defining integral property of the conditional expectation given \(X\). Substituting the conditional-density ratio in the bracket gives the claimed formula for \(f_X\)-almost every \(x\). \(\square\)

The integrability assumption guarantees that the conditional integral is finite for \(f_X\)-almost every \(x\). For nonnegative measurable \(g\), the same integral formula holds in the extended nonnegative sense by Tonelli’s theorem, even if its expectation is infinite.

Common Mistakes and Practical Checks

  • Dividing by the wrong marginal. To find the density of \(Y\) given \(X=x\), divide by \(f_X(x)\), not \(f_Y(y)\). The denominator is the density of the variable being conditioned on.
  • Ignoring the support section. If the joint support requires \(y<x\), then the conditional density at \(X=x\) must be zero for \(y\geq x\). The ratio does not make impossible pairs possible.
  • Failing to check normalization. A proposed conditional density should integrate to one in the variable being conditioned. If it does not, recheck the marginal integral, the ratio, and the support limits.
  • Treating a zero marginal as a valid denominator. When \(f_X(x)=0\), the ratio is undefined and no pointwise conditional density is determined by it. Conditional densities are relevant up to sets of \(x\)-values having probability zero.
  • Confusing a conditional mean with a fixed number. The expression \(E[Y\mid X=x]\) may depend on \(x\), as the examples show. It is obtained by integrating \(y\) against the conditional density at that particular \(x\).

A reliable calculation follows a short sequence: identify the joint support; integrate the joint density over the variable being removed; divide by the marginal of the conditioning variable; state the conditional support; and verify that the conditional density integrates to one. Only after these checks should the conditional expectation integral be evaluated.

Check Your Understanding

Use the joint support and the marginal density carefully in each question.

  1. If \(f_{X,Y}(x,y)=3\) on \(0<y<x<1\) and zero elsewhere, calculate \(f_X(x)\). Is this a valid joint density as stated? Explain.
  2. For a joint density supported on \(0<x<y<\infty\), what are the integration limits for finding \(f_X(x)\) at a fixed positive \(x\)?
  3. Why does \(f_{Y\mid X}(y\mid x)\) have denominator \(f_X(x)\) rather than \(f_Y(y)\)?
  4. State the normalization check for a conditional density of \(Y\) given \(X=x\).
  5. For which \(x\)-values is the ratio formula not defined, and why can the conditional density be assigned arbitrarily on such values when they have probability zero under \(X\)?