From a Joint Density to a Conditional Density
A joint density describes the distribution of a random vector all at once. But many questions are conditional: among individuals with a particular value, or range of values, for one component, how is another component distributed? For continuous random variables, the answer comes from comparing the joint density with the marginal density of the variable being conditioned on.
Let \(X\in\mathbb{R}^p\) and \(Y\in\mathbb{R}^q\) have joint density \(f_{X,Y}(x,y)\), and let \(f_X(x)\) be the marginal density of \(X\), obtained by integrating the joint density over \(y\). Where \(f_X(x)>0\), the ratio of these densities gives a conditional density for \(Y\) given \(X=x\).
The phrase “for each relevant \(x\)” matters. The ratio is defined directly only where \(f_X(x)>0\). Moreover, a density can be changed on a set of measure zero without changing the distribution it describes. Consequently, conditional distributions specified by densities are determined only for almost every \(x\) under the distribution of \(X\). At an individual value where \(f_X(x)=0\), the ratio does not define a conditional density; additional model structure may sometimes specify a useful version there, but the density formula alone does not.
For any measurable set \(B\subseteq\mathbb{R}^q\), the conditional probability is obtained by integrating the conditional density over \(B\):
Likewise, if \(g(Y)\) is integrable, its conditional expectation is the integral of \(g\) against that density. For a vector-valued \(Y\), expectations are taken component by component.
Worked Conditional Calculations
Worked Example: A Uniform Conditional Distribution on a Triangle
Suppose the joint density is \(f_{X,Y}(x,y)=2\) when \(0<y<x<1\), and is zero elsewhere. Find the marginal density of \(X\), the conditional density of \(Y\) given \(X=x\), and the conditional mean and variance.
First integrate over the possible values of \(y\) at each \(x\). The support requires \(0<y<x\), so
The marginal integrates to one: \(\int_0^1 2x\,dx=1\). For \(0<x<1\), divide the joint density by this marginal:
This is the uniform density on \((0,x)\), and its integral is \(x(1/x)=1\). For example, the conditional probability that \(Y<x/2\) is
The conditional mean and second moment are
Therefore,
Worked Example: A Conditional Support That Changes with \(x\)
Let \(f_{X,Y}(x,y)=2\) on \(0<x<y<1\), and zero elsewhere. Find \(f_{Y\mid X}(y\mid x)\), then calculate the conditional mean and the probability that \(Y>3/4\) when \(X=1/2\).
For fixed \(x\), the joint support allows \(x<y<1\). Integrating over that interval gives
This is a valid marginal density because \(\int_0^1 2(1-x)\,dx=1\). Thus
The conditional support depends on \(x\): it is the interval from \(x\) to \(1\), not the entire unit interval. Integrating gives
At \(x=1/2\), the conditional density is \(2\) on \((1/2,1)\). Hence
Worked Example: An Exponential Conditional Density
Suppose \(f_{X,Y}(x,y)=xe^{-x}e^{-xy}\) for \(x>0\) and \(y>0\), and is zero elsewhere. Find the conditional distribution of \(Y\) given \(X=x\), its mean and variance, and \(P(Y>2\mid X=3)\).
Integrating out \(y\) yields
Here \(\int_0^\infty e^{-xy}\,dy=1/x\) because \(x>0\). The marginal is normalized, since \(\int_0^\infty e^{-x}\,dx=1\). Dividing by it gives
This is an exponential density with rate \(x\). Direct integration, or the standard exponential moments, gives \(E[Y\mid X=x]=1/x\) and \(E[Y^2\mid X=x]=2/x^2\). Therefore,
For \(x=3\), integrating the conditional density over \(y>2\) gives
Why the Density Ratio Works
The ratio is not just a convenient recipe. It is normalized for almost every \(x\) with positive marginal density, and it reproduces joint probabilities when integrated against the marginal density of \(X\).
Proof. Since the joint density is nonnegative, Tonelli’s theorem permits the iterated integrals below. For any \(x\) with \(0<f_X(x)<\infty\),
A marginal density is finite almost everywhere; thus this calculation applies for almost every \(x\) where it is positive. For the probability identity, first express the joint probability as an integral of its density and then substitute the ratio wherever \(f_X(x)>0\):
The set of \(x\)-values where \(f_X(x)=0\) contributes zero to the joint integral, so values assigned to the conditional probability there do not change the identity. \(\square\)
Conditional Expectations and Variances
For a scalar \(Y\), define the conditional mean \(m(x)=E[Y\mid X=x]\) by integrating \(y\) against the conditional density, whenever that integral exists. The conditional variance measures the remaining variation in \(Y\) at that value of \(X\):
These quantities are functions of \(x\), not generally constants. For a random vector \(Y\), the conditional mean is a vector and the conditional covariance matrix is the conditional expectation of \((Y-m(x))(Y-m(x))^\mathsf{T}\), when its entries exist.
Proof. Write \(m(x)=E[Y\mid X=x]\). Under the first moment condition, Fubini’s theorem applies to the integrable function \(y f_{X,Y}(x,y)\). Using the conditional-density ratio gives
For the variance identity, finite second moment ensures the terms below are integrable. At each \(x\), expand \(Y-E[Y]\) as \((Y-m(x))+(m(x)-E[Y])\), square, and take the conditional expectation. The cross term is zero because \(E[Y-m(x)\mid X=x]=0\). Thus
Integrating both sides with respect to \(f_X(x)\,dx\), and using the first identity to identify \(E[m(X)]=E[Y]\), gives
This proves both identities under the stated moment conditions. \(\square\)
Common Pitfall: Ignoring the Conditional Support
A frequent error is to divide the densities correctly but then integrate over a support that is too large. In the triangular example, \(Y\mid X=x\) is supported on \(0<y<x\), not on all positive \(y\). Integrating \(1/x\) from \(0\) to \(1\) would give \(1/x\), not \(1\), and would fail the basic test for a density. The conditional support must be read from the joint support after fixing \(x\).
Another mistake is to use the ratio at an \(x\) where \(f_X(x)=0\), or to assume a conditional distribution at a single point is uniquely determined by the joint law. The ratio is justified where the marginal density is positive and determines the conditional law only almost everywhere. This distinction is especially important when an expression is evaluated at a specific conditioning value.
Conditional densities are useful because they turn questions about dependence into calculations at fixed values of one component. They also separate within-group variability, represented by the conditional variance, from variability in the conditional mean across groups. The total-variance identity makes that separation precise.
Check Your Understanding
Use the density ratio and keep track of the support in each calculation.
- For a joint density supported on \(0<y<x<1\), what is the range of \(y\) when calculating \(f_{Y\mid X}(y\mid x)\)?
- Why does a conditional density obtained by the ratio need to integrate to one for each relevant \(x\)?
- What condition is required to define the density ratio \(f_{X,Y}(x,y)/f_X(x)\) at a given value of \(x\)?
- State the integral formula for \(E[g(Y)\mid X=x]\).
- In the law of total variance, what do the two terms on the right-hand side represent mathematically?