Expected value of a continuous random variable: interchanging the order of integration I have come across a proof of the following in Ross's book on Probability -
For a non-negative continuous random variable Y with a probability density function $f_Y$
$$
\mathrm{E} [Y] = \int_0^\infty P[Y \geq y]dy
$$
The author proves it by using 
$$
\int_0^\infty \int_y^\infty f_Y(x)dxdy = \int_0^\infty (\int_0^x dy)  f_Y(x)dx
$$
He refers to it as "interchanging the order of integration".
I have studied a fair amount of Calculus from Apostol's books (Vol 1 & 2). But I still can't seem to provide a proof of this equation. How does one go about proving this last equation?
 A: we have 
\begin{align*}
  \int_{[0,\infty)}\int_{[y,\infty)} f_Y(x)\; dx\, dy 
  &= \int_{[0,\infty)}\int_{[0,\infty)}\chi_{[y,\infty)}(x)f_Y(x)\;dx\,dy\\
  &= \int_{[0,\infty)}\int_{[0,\infty)}\chi_{[y,\infty)}(x)f_Y(x)\;dy\,dx\\
  &= \int_{[0,\infty)}\int_{[0,\infty)}\chi_{[y,\infty)}(x)\;dy\cdot f_Y(x)\;dx\\
  &= \int_{[0,\infty)} \int_{[0,\infty)} \chi_{[0,x]}(y)\; dy\cdot f_Y(x)\; dx\\
  &= \int_{[0,\infty)} xf_Y(x)\; dx\\
  &= E(Y)
\end{align*} 
where $\chi_A$ denotes the indicator function of a set $A$.
A: To complete martini's proof, let me remark that changing the order of integration is allowed in this case by Tonelli's Theorem.
A: Intuitively, your double integral 
$$\int_0^\infty \int_y^\infty f_Y(x)\,\mathrm dx\, \mathrm dy$$
is the integral of $f_Y(x)$, regarded as a function of two variables $x$
and $y$, over the first octant $\{(x,y)\colon 0 \leq y \leq x < \infty\}$
set up by fixing $y$, letting $x$ vary from $y$ to $\infty$, (the inner
integral) and then letting $y$ vary from $0$ to $\infty$ (the outer integral).
An alternative way of computing this integral is to fix $x$, let $y$ vary
from $0$ to $x$, and then let $x$ vary from $0$ to $\infty$. This results
in the other expression
$$\int_0^\infty \left [ \int_0^x \, \mathrm dy\right]f_Y(x)\,\mathrm dx.$$
The formal way of transforming one integral into another has been given by 
martini in his answer, with the interchange in the order of integration
being justified via Tonelli's theorem as Rasmus points out.  But let me 
say that at the level
of Ross's A First Course in Probability (assuming that is the book
you mean) the fine points and formal proofs are probably not expected
to be considered by the average reader who is allowed to blithely 
interchange order of integration etc.
Another way of looking at the problem in intuitive fashion is to note that
$$\int_0^\infty [1 - F(x)]\,\mathrm dx$$
computes the area between the CDF curve $F(x)$ and the line at 
height $1$ above the $x$ axis. One way to do this is to divide the 
region into thin vertical strips, so that the strip at $x$ extends from $(x,F(x))$ to $(x,1)$ and is of width $\Delta x$. Find Riemann sums, take limits as the width goes to $0$, etc.and you get 
$$\int_0^{\infty} [1-F(x)]\mathrm dx.$$
The other way is to divide into thin horizontal strips with the strip at height $F(x)$ above the axis having length $x$ since it extends from $(0,F(x))$ to $(x,F(x))$, and has thickness
(height) $F(x+\Delta x) - F(x)$. The area is thus approximately $x\cdot [F(x+\Delta x) - F(x)]\Delta x \approx xf(x)\Delta x$,  and proceeding with Riemann sums, etc., the 
end result is
$$\int_0^{\infty} x f(x)\, \mathrm dx$$ 
which of course is the expected value. 
