Wish to identify what I'm doing wrong when finding the $\operatorname E(X\mid Y=5)$ of the following: $$f(x, y)=\begin{cases} 1/6 & \text{if } 0<x<2, 0<y<6-3x \\ 0 & \text{otherwise} & \end{cases}.$$

My working: $$\begin{align}\operatorname E(X\mid Y=5)~&=~\int_0^2 x \frac{\frac{1}{6}}{f(y)} \, \mathsf d x\end{align}$$ where $$\begin{align}\mathsf f(y)~&=~\int_0^{\frac{-y+6}{3}} \frac{1}{6} \,\mathsf d x = \frac{6-y}{18}\end{align}$$

Therefore, $$\begin{align}\mathsf E(X\mid Y{=}5)~&=~\int_0^2 x \frac{\frac{1}{6}}{\frac{6-y}{18}}\,\mathsf d x \mathsf ~&=~\int_0^2 x \frac{\frac{1}{6}}{\frac{6-5}{18}}\,\mathsf d x~&=~\int_0^2 3x \,\mathsf d x \end{align} = 6$$

But then when I compute $\operatorname{Var}(X\mid Y=5),$ the answer is getting negative, which is impossible. So I think that I might have done something wrong when calculating the expectation.

My working for Variance: $$\operatorname{Var}(X\mid Y=5) = \operatorname E(X^2\mid Y=5) - (\operatorname E(X\mid Y=5) )^2 = 8 - 6^2 = -28$$

I appreciate any help.

  • 1
    $\begingroup$ you forgot the constraint on the support of $X$ given $Y=y.$ $\endgroup$
    – Xi'an
    Nov 1, 2018 at 21:23

1 Answer 1


Think about this geometrically: we've got $(X,Y)$ uniformly distributed over the right triangle with vertices at $(0,0)$, $(2,0)$, and $(0,6)$.

If we imagine sampling over and over from this region uniformly, we can picture $E(X\mid Y=5)$ as the average $x$ coordinate of the points that end up on the horizontal line $y=5$. All of these points will necessarily have $0 < x < 1/3$, since if $x \geq 1/3$ then $y = 5$ can't happen, and since the points are uniform over this line, this image suggests $E(X\mid Y=5) \stackrel {\text{?}}= 1/6$ (this is the midpoint of the range of $x$ points that can end up on this line).

Checking this with calculus, the issue with what you did is the limits of integration for $x$ also depend on $y$. If $y = 5$ is observed then the biggest that $x$ can be is $1/3$, so really $$ E(X\mid Y=5) = \int_0^{1/3}x \frac{3}{6-y}\,\text dx = 3 \cdot \frac 12 x^2\bigg|_{x=0}^{x=1/3} = \frac 16. $$

Another quick sanity check is that $E(X\mid Y)$ has to be within the range of $X$, so $E(X\mid Y=5)\neq 6$ can be recognized as incorrect before the negative variance shows up.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.