Applying Fubini's theorem to find the expected value of a random variable

53 Views Asked by At

I don't understand how we get this equality:

With $y$ non negative, $$\int_0^{\infty}\left(\int_y^{\infty}f(x)dx\right) dy$$ $$=\int_0^{\infty}\left(\int_0^{x}dy\right)f(x)dx$$

When I apply Fubini, I get

$$\int_0^{\infty}\left(\int_y^{\infty}f(x)dx\right) dy$$ $$=\int_y^{\infty}\left(\int_0^{\infty}dy\right)f(x)dx$$

$f$ is the probability density function of a continuous random variable $Y$.

Edit: Ok so when the bounds of the double integral aren't constants, we have to consider more carefully the area over which we are integrating. In the initial integral, we are integrating over the area formed by $0 \leq y \leq \infty$ and $y \leq x \leq \infty$, where we integrate by $x$ first (integrating "vertically" on the xy axis). If we wish to integrate by $y$ first (integrating "horizontally" on the xy axis), we must define the area over which we are integrating like this: $0 \leq y \leq x$ and $0 \leq x \leq \infty$. These become the bounds of the new integral.