From a Continuous Observation to a Conditional Mean
When the conditioning variable is continuous, conditioning on its exact value is not the same calculation as conditioning on an event with positive probability. For a continuous random variable \(Y\), it is often the case that \(P(Y=y)=0\) for every fixed \(y\). The useful object is instead a conditional density: it describes the distribution of another variable \(X\) at a specified value \(y\) of \(Y\).
Once that density is available, the conditional expectation of a function \(g(X)\) is an integral over the possible values of \(X\). The result depends on \(y\), so it is a function of the observed conditioning value. In this tutorial, \(X\) is real-valued, \(Y\) is continuous, and the function \(g\) is measurable.
The integral is over the support of the conditional density; writing \(\mathbb{R}\) simply allows the density to be zero outside that support. The choice \(g(x)=x\) gives the conditional mean \(E[X\mid Y=y]\). Choices such as \(g(x)=x^2\) or \(g(x)=e^{-x}\) produce other conditional expectations.
The Density-Ratio Formula
Suppose \((X,Y)\) has joint density \(f_{X,Y}(x,y)\) and \(Y\) has marginal density \(f_Y(y)\). Wherever \(f_Y(y)>0\), a standard version of the conditional density is the ratio of the joint density to the marginal density:
Density formulas are understood almost everywhere: densities can be changed on sets of Lebesgue measure zero without changing the distribution. Accordingly, the ratio gives a standard conditional-density version for almost every relevant \(y\). At a point where \(f_Y(y)=0\), the ratio is undefined; the conditional density, and hence the conditional expectation, may be assigned a value there without affecting the random variable \(E[g(X)\mid Y]\). A formula evaluated at a particular \(y\) should therefore be interpreted using a specified version, and only when its integral is well-defined.
Why the Integral Is the Right Calculation
The density calculation can be checked by averaging over any measurable set of conditioning values. Let \(B\) be a measurable subset of the real line, and suppose \(E[|g(X)|]<\infty\). For the density-ratio version, multiplication by the marginal density cancels the denominator:
The identity says that the conditional integral, when averaged over the values of \(Y\) in \(B\), recovers the corresponding joint expectation. It also explains why the conditional mean is not obtained by substituting a single event \(Y=y\) into an ordinary ratio of probabilities: the density ratio, rather than \(P(Y=y)\), supplies the relevant conditional distribution.
To verify this, use the joint-density factorization \(f_{X,Y}(x,y)=f_{X\mid Y}(x\mid y)f_Y(y)\) for almost every \((x,y)\). Since the integrand below is nonnegative, Tonelli's theorem permits the order of integration:
A nonnegative function with finite integral can be infinite only on a set of measure zero under the integrating measure. Thus the inner integral is finite for \(f_Y\)-almost every \(y\), as claimed. For signed \(g\), absolute finiteness allows the corresponding integrals to be used without ambiguity. This result does not guarantee finiteness at every individual value of \(y\).
Worked Calculations
Worked Example: A Conditional Mean on a Triangular Support
Suppose a joint model for \(X\) and \(Y\) has density \(f_{X,Y}(x,y)=2\) on \(0<x<y<1\), and zero elsewhere, with marginal density \(f_Y(y)=2y\) for \(0<y<1\). Find \(E[X^2\mid Y=y]\) for \(0<y<1\).
First form the conditional density using the density ratio. On the support \(0<x<y<1\),
It is zero outside \(0<x<y\). As a check, its integral over that interval is \(\int_0^y (1/y)\,dx=1\). Now use \(g(x)=x^2\):
The answer changes with \(y\), as a conditional expectation should. For example, if \(y=0.6\), then \(E[X^2\mid Y=0.6]=0.6^2/3=0.12\). The support matters: integrating from 0 to 1 instead would ignore the restriction \(X<y\).
Worked Example: A Function of an Independent Exponential Variable
Let \(X\sim\operatorname{Exponential}(\lambda)\), with density \(\lambda e^{-\lambda x}\) for \(x>0\), where \(\lambda>0\), and suppose \(X\) is independent of a continuous variable \(Y\). Find \(E[e^{-tX}\mid Y=y]\) for \(t\geq 0\).
Independence means that the conditional density of \(X\) given \(Y=y\) is its marginal density, for almost every \(y\) under the distribution of \(Y\). Therefore,
The integral is finite because \(\lambda+t>0\). The result does not depend on \(y\), which is consistent with independence: observing \(Y\) does not change the distribution used to average the function of \(X\). For instance, if \(\lambda=2\) and \(t=3\), the conditional expectation is \(2/(2+3)=0.4\).
Worked Example: A Squared Conditional Mean in a Bivariate Normal Model
Suppose \(X\) and \(Y\) are jointly normal, each has mean zero and variance one, and their correlation is \(0.6\). In this model the conditional distribution is \(X\mid Y=y\sim N(0.6y,0.64)\). Calculate \(E[X^2\mid Y=y]\), then evaluate it at \(y=1\).
For a variable with mean \(m\) and variance \(v\), its second moment is \(v+m^2\), since \(E[X^2]=\operatorname{Var}(X)+(E[X])^2\). Here the conditional mean is \(0.6y\), and the conditional variance is \(0.64\). Thus
At \(y=1\), this gives \(E[X^2\mid Y=1]=0.64+0.36=1\). The conditional second moment is not just the square of the conditional mean: that square is \(0.36\) at \(y=1\), and the remaining \(0.64\) is the conditional variance.
Common Pitfalls and Interpretation
The most common error is to treat a conditional expectation given a continuous value as an ordinary conditional mean on the event \(\{Y=y\}\). Since that event typically has probability zero, dividing \(E[g(X)\mathbf{1}_{\{Y=y\}}]\) by \(P(Y=y)\) gives no usable calculation. The correction is to use the conditional density at \(y\) and integrate \(g(x)\) against it.
- Dropping the support. Integrate over the values \(x\) allowed by \(f_{X\mid Y}(x\mid y)\), not over a convenient interval chosen independently of \(y\).
- Forgetting the denominator. Where \(f_Y(y)>0\), the conditional density is the joint density divided by the marginal density. The joint density alone need not integrate to one over \(x\) at fixed \(y\).
- Confusing the conditional mean with a plug-in value. In general, \(E[g(X)\mid Y=y]\) is not \(g(E[X\mid Y=y])\). For the normal example, \(E[X^2\mid Y=y]=0.64+0.36y^2\), not merely \((0.6y)^2\).
- Claiming a value where the ratio is undefined. If \(f_Y(y)=0\), the density-ratio formula cannot be used there. Conditional expectations are defined up to changes on \(Y\)-null sets.
The practical sequence is simple: identify the conditional density and its support, choose the function \(g\), and evaluate its conditional-density integral. Then check that the integral exists and that the answer is interpreted on values of \(y\) for which the chosen density version applies.
Check Your Understanding
Try each question by writing the relevant conditional-density integral before simplifying it.
- If \(X\mid Y=y\) is uniform on \((0,y)\) for \(y>0\), what is \(E[X\mid Y=y]\)?
- Why does \(P(Y=y)=0\) not prevent us from defining a conditional mean given \(Y=y\)?
- For what values of \(y\) can the density-ratio formula be used directly, and what is the issue when \(f_Y(y)=0\)?
- If \(E[|g(X)|]<\infty\), what does the conditional-integrability result guarantee, and what does it not guarantee at every individual \(y\)?
- For \(X\mid Y=y\sim N(2y,3)\), calculate \(E[X^2\mid Y=y]\).