$X$ is uniformly distributed in $[0,1]$, and $Y$ is uniformly distributed in $[0,X]$
(a) Find $\mathbb{E}(Y)$ and $\text{Var}(Y)$
Solution:
By conditioning on $X$, we obtain the first two orders of statistics of $Y$ as $\mathbb{E}(Y)=\mathbb{E}_X[\mathbb{E}_Y(Y|X)]=\mathbb{E}_X[\frac{X}{2}]=\frac14$
$\mathbb{E}(Y^2)=\mathbb{E}_X[\mathbb{E}_Y(Y^2|X)]=\mathbb{E}_X[\frac{X^2}{3}]=\frac19$
$\text{Var}(Y)= \mathbb{E}(Y^2)-\mathbb{E}^2(Y) = \frac19-(\frac14)^2=\frac{7}{144}$
So, I understand why E[Y]=1/4 without doing any integrals and stuff, but I'm a bit confused as to how to get the E[Y^2] value.
From where I understand you have to take the integral from 0 to x of y^2/x. But I don't understand where they got this integral from.