Changing order of integration of $\int_0^{\infty}\int_{a}^{\infty} f_{Y}(x) dx\ dy $? I am trying to follow a proof where $Y$ is a continuous random variable with probability density function $f_{Y}$. 
What I don't get is how or why changing order of integration of the following


*

*$\int_0^{\infty} P(Y \gt a) dy = \int_0^{\infty}\int_{a}^{\infty} f_{Y}(x) dx\ dy $       leads to 

*$ = \int_0^{\infty}(\int_{0}^{x}\ dy) f_{Y}(x)\ dx$
What are the explicit algebraic or calculus manipulations which take us from 1 to 2?  
 A: I will guess what would've been the correct expression. I am guessing 
$$
\int_0^{\infty} P(Y > y) dy 
$$
is the integral you want to compute (there is a theorem in which this expression appears...). 
$$
\int_0^{\infty} P(Y > y) dy = \int_0^{\infty} \int_y^{\infty} f_Y(x) \, dx \, dy.
$$
Now you want to start integrating this integral with respect to $y$ instead of $x$ first. The region of the $xy$-plane you are integrating over is 
$$
\{ (x,y) \, | \,0 \le y \le x \}
$$
because $y$ has no constraint except being positive, but $x$ has the constraint of being greater than $y$. If you swap these conditions around, $x$ has no constraint, but $y$ has the constraint of being smaller than $y$. This means that by Fubini's theorem,
$$
\int_0^{\infty} \int_y^{\infty} f_Y(x) \, dx \, dy = \int_0^{\infty} \int_0^x f_Y(x) \, dy \, dx.
$$
Note that the order of integration has changed, so that since $f_Y(x)$ does not depend on $y$, the first integral can be factored : 
$$
\int_0^{\infty} \int_0^x f_Y(x) \, dy \, dx = \int_0^{\infty} \left( \int_0^x \, dy \right) f_Y(x) \, dx = \int_0^{\infty} x \, f_Y(x) \, dx = \mathbb E [ Y ],
$$
which I'm guessing was the point of this computation.
Hope that helps,
