Consider the joint probability density function $$ f_{X,Y}(x,y) = \begin{cases} \frac1y,& 0<x<y, \ \ 0<y<1\\ 0,& \text{otherwise.} \end{cases} $$ (a) Find the marginal probability density function of $Y$ and identify its distribution.
(b) Find the conditional probability density function of $X$ given $Y=y$ and hence find the mean and variance of $X$ conditional on $Y=y$.
I've attempted part a of the question, but I think I’ve done it wrong so I’m getting errors in part b. So far, I have integrated the function with respect to $x$ to get $f_y(y)= \frac{x}{y}=1$ using the limits $y$ and $0$. I am unsure where I have gone wrong.
To find the marginal density of $Y$, we integrate $f_{X,Y}$ over all possible values of $x$: $$ f_Y(y) = \int_0^y \frac1y\ \mathsf dx = \mathsf 1_{(0,1)}(y). $$ This is just the uniform distribution on $(0,1)$.
The conditional density of $X$ given $y=y$ is found by dividing the joint density by the marginal density of $Y$:
$$ f_{X\mid Y=y}(x\mid y) = \frac{f_{X,Y}(x,y)}{f_Y(y)} = f_{X,Y}(x,y),\ 0<y<1. $$ Hence the mean of $X$ conditional on $Y=y$ is $$ \int_0^y \frac xy\ \mathsf dx = \frac y2 $$ and the variance of $X$ conditional on $Y=y$ is $$ \int_0^y \frac{\left(x-\frac y2\right)^2}y\ \mathsf dx = \frac{y^2}{12}. $$