Expectation of Y in a joint distribution? Let $X$ be a uniformly chosen number in the interval $(0, 1)$. Choose a point P uniformly from the triangle with vertices at $(X,0), (0,X)$, and $(0,0)$. Let $Y$ be the $y$ coordinate of the point P . Compute $E(Y )$.
Here is my work:

Here is what I know:
$E(Y) = \int_{-\infty}^{\infty}E(Y|X=x)\ * \ f_x(x)\ dx$
and
$E(Y|X=x) = \int_{-\infty}^{\infty}y * f_{Y|X}(y|x)\ dy$
So since, the blue line can be expressed as $y = X - x$, then the boundaries are $0<y<X-x$ and $0<x<1$
Then I said:
\begin{equation}
E(Y)=\int_{0}^{1}\int_{0}^{X-x}y*f_{Y|X}(y|x)*f_{X}(x)\ dy\ dx
\end{equation}
However, I'm stuck since, I don't know how to find $f_{Y|X}(y|x)$
Am I doing this right? If so, how do I find $f_{Y|X}(y|x)$ so I can complete the problem?
 A: When $X=x$, the point $P$ is uniformly distributed in the triangle $\triangle(0,0)(0,x)(x,0)$ so the density of $Y$ at $y$ is measured by the length of the horizontal line-segment at height $y$ passing through the triangle divided by the area of the triangle.
$$f_{Y\mid X}(y\mid x) = \frac{2(x-y)}{x^2}\quad \mathbf 1_{y\in[0;x]}$$
Then: $\mathsf E(Y)$ $ \displaystyle = \int_0^1\int_0^x y f_{Y\mid X}(y\mid x)f_X(x)\operatorname d y\operatorname d x \\\displaystyle = \int_0^1\int_0^x \frac{2y(x-y)}{x^2}\operatorname d y\operatorname d x$
A: We find $E(Y)$, given that $X=x$. One slightly klunky way of doing this is to find the conditional distribution of $Y$ given that $X=x$. 
Let $y\le x$. Then the probability that $Y\gt y$ is the area of the part of the triangle above the horizontal line at height $y$. This triangle has legs $x-y$, so area $(1/2)(x-y)^2$. So the conditional probability that $Y\gt y$ is $\frac{(x-y)^2/2}{x^2/2}$. It follows that the conditional density of $Y$ is $\frac{2(x-y)}{x^2}$. The conditional expectation of $Y$ is therefore 
$$\int_0^x \frac{2y(x-y)}{x^2}\,dx.$$
This is $\frac{2}{3}x$.
For the expectation of $Y$, calculate $\int_0^1 \frac{2}{3}x\,dx$. 
