let $X$ be uniformly distributed in the unit interval $(0, 1)$. find density of $Y$ which is uniformly distributed on interval $(0,X)$. let $X$ be uniformly distributed in the unit interval $(0, 1)$. find density of $Y$ which is uniformly distributed on interval $(0,X)$.
MY WORKING
Since $Y$ is uniformly distributed over $(0,X)$, the pdf of $Y$ is: $f_Y(y)=\frac{1}{x-0}=\frac{1}{x}.$
I know the result doesn't make any sense. The pdf should be in terms of $y$ not $x$, also I have applied the correct procedure for finding the pdf of uniformly distributed random variable which is: $f_X(x)=\frac{1}{b-a}$. where $X$ is uniformly distributed over $(a,b)$. So I dont understand Where am I making mistake?
Any guidance will be appreciated. Thanks
 A: You have to condition on $X$ and then take the expectation.
$P(Y \leq y)=EP(Y\leq y|X)$ and $P(Y\leq y|X)=\frac y X $if $y \leq X$ and $1$ if $y >X$. So  $P(Y \leq y)=\int_y^{1}\frac y x dx+y =y-y\ln y$ for $0<y<1$. Differentiating this we get $f_Y(y)=-\ln y, 0<y<1$.
A: Here's a method using pdf's and known formulas
You have that $f_{Y|X}(y)=\frac{f_{X,Y}(x,y)}{f_{X}(x)}$
Where $f_{Y|X}$ denotes the conditonal density , $f_{X,Y}$ denotes the joint density and $f_{X}$ denotes the marginal density(or simply the density of $X$) .
Hence $f_{Y|X}(y)\cdot f_{X}(x)=f_{X,Y}(x,y)$
And we know that integrating the joint density wrt $x$ would give you the marginal density of $Y$ (or simply the density of $Y$) .
So what you have found out is $f_{Y|X}(y)$ which is just $f_{Y|X}(y)=\begin{cases} \frac{1}{x}\,,0< y<x \\ 0\,,\text{elsewhere}\end{cases}$ .
And $f_{X}(x)=\mathbf{1}_{\{0< x<1\}}$
Thus multiplying we have  $f_{X,Y}(x,y)=\frac{1}{x}\mathbf{1}_{\{y\leq x\leq 1\}}$  .
Hence $\int_{-\infty}^{\infty}f_{X,Y}(x,y)\,dx = f_{Y}(y)$
And we have $\int_{-\infty}^{\infty}f_{X,Y}(x,y)\,dx=\int_{y}^{1}\frac{1}{x}\,dx=-\ln(y)\cdot \mathbf{1}_{\{0<y<1\}}$ .
That is $f_{Y}(y)=-\ln(y)\,,0<y<1$
Note that while I say "the" density, I should really say "a" density as they may be equal upto a set of measure $0$. Ignore this if it confuses you now.
Otherwise . You can always use the formula that $\Bbb{E}(Y)=\Bbb{E}(\Bbb{E}(Y|X))$ . Apply this to the indicator $\mathbf{1}_{\{Y\leq y\}}$ to get the cdf as @geetha290krm did .
