Say I have two uniformly distributed random variables as follows: $X$ ~ $U(a,b)$ $Y$ ~ $U(0, X)$. How would I go about finding the expectation of $Y$.
Obviously the expectation of $X$ is simple, but how do find the expectation of the RV when it is distributed with respect to another RV?
The problem I have is a little different than this so any explanation of the idea behind such a situation would be great.
You are told that $X\sim \text{unif}(a,b)$, and that $Y|X\sim\text{unif}(0, X)$.
The simplest answer is to use the law of total expectation, which gives
$$E[Y] = E\{E[Y|X]\} = E\left[\frac{0+X}{2}\right] = \frac{1}{2}E[X] = \frac{1}{2}\cdot\frac{a+b}{2}.$$
You can also use $$E[Y] = \int_{-\infty}^\infty E[Y|X = x] f_X(x)\,dx = \int_a^b \frac{0+x}{2}\cdot\frac{1}{b-a}\,dx$$ if you haven't been taught/don't cover the previous law.