Finding conditional expectation When I need to find $E(X|Y=1)$ and have: $$f(x,y)=\begin{cases}\lambda^3xe^{-\lambda y} & 0\lt x\lt y\\ 0 & \text{elsewhere}\end{cases}$$ Do I need to find both marginal densities to do this? I know that the definition of $E(X|Y=y)=$$$\begin{align}\int_{-\infty}^{\infty} g(x)f_X(x|Y=1)dx\\ =\int_{-\infty}^{\infty}g(x)P(x|Y=1)dx\\=\int_{-\infty}^{\infty}g(x)*\frac{f(x,y)}{f_Y(y)} dx\end{align}$$ This is the definitiion given in my textbook. Is the $g(x)$ supposed to be the marginal density of $X$? 
 A: I think your book is telling you $E[g(X)\mid Y = y]$ for arbitrary measurable
function $g(\cdot)$, not $E[X\mid Y = y]$. And yes, you do need to compute the
marginal density of $Y$ in order to divide $f_{X,Y}(x,y)$ in your formula.
But you don't need to find both marginal densities, and in this simple
case, it is even unnecessary to compute $f_Y(y)$ explicitly; one can get
find $f_{X\mid Y=1}$ without knowing the formula for $f_Y(y)$ or what
kind of random variable $Y$ is (it is a Gamma random variable, by the way).
The way I would approach the problem is to say that given $Y = 1$, 
the conditional density of $X$ has shape given by $f(x,1)$ which
is a linear function of $x$ for $x \in (0,1)$. The graph shows a
triangle whose area  must
equal $1$ in order to get a valid density. So the conditional
density must be $$f_{X\mid Y=1}(x\mid Y=1) = 2x\mathbf 1_{(0,1)}$$ and so the
mean is $\frac{2}{3}$.
A: First you need to find $f_Y(y) = \int_{-\infty}^{\infty}f(x,y)dx$.
Then,
$$E(X|Y=y) = \int_{-\infty}^{\infty}x\frac{f(x,y)}{f_Y(y)}dx$$
The formula you have written is correct for $E(g(X)|Y=y)$, which is a generalized version of the above.
