Why is this True ? It's probability question, but really an multivariable integration question I'm given that $X$ is a non-negative continuous random variable show that
$$E(X) = \int^\infty_0 [1-F(x)]\,dx$$
$F(x)$is a cdf
The solution is following
$$\int^\infty_0 (1-F(x)) \, dx = \int^\infty_0 P(X > x) \, dx = \int^\infty_0 \int^\infty_x f_x(t) \, dt\,dx = \int^\infty_0 f(t) \left(\int^t_0 dx\right) \, dt$$
I don't understand why is it true for the last two equality, when the order $dx$ and $dy$ been changed. What's the theorem behind it ? (i only know basic double integration calculation)
 A: You are switching the order of integration over a region that is an infinite triangle, that is the region between $x=0$ and the line $x=t$ in the first quadrant; the first expression integrates from the line to infinity first, whereas the second integrates from zero to the line first.
A: $$
\int^\infty_0 \int^\infty_x f_X(t) \, dt\,dx = \int^\infty_0 f_X(t) \left(\int^t_0 dx\right) \, dt\text{ ?}
$$
Firstly, I've changed $f_x$ to $f_X$ above, for a reason I expect will be clear to you since your writing $\Pr(X>x)$ would seem to indicate that you know the difference between $X$ and $x$.
$$
\int^\infty_0 \left(\int^\infty_x f_X(t) \, dt\right) \, dx
$$
The variable $x$ runs from $0$ to $\infty$.
For each value of $x$, the other variable $t$ runs from $x$ to $\infty$.
This says we're looking at the set of values of $x$ and $t$ for which $0<x<t<\infty$.
The the integral that is inside the other one says $\displaystyle\int_x^\infty\cdots\cdots \, dt$, so it is explicit about the thing over the $\underbrace{\text{underbrace}}$ in this expression: $0<\underbrace{x<t<\infty}$.
Now let's look at $0<x<t<\infty$ in a different way: $\underbrace{0<x<t}<\infty$.
This says that for any particular value of $t$, the other variable, $x$, runs from $0$ to $t$.  As for $t$, it runs from $0$ to $\infty$.  So we have
$$
\int_0^\infty \cdots\cdots\,dt
$$
and then inside that, and so for every fixed value of $t$, we have $\displaystyle\int_0^t\cdots\cdots\,dx$.  So we have
$$
\int_0^\infty \left( \int_0^x\cdots\cdots\,dx \right)\,dt.
$$
This gets us
$$
\int_0^\infty \left( \int_0^t f_X(t)\,dx \right)\,dt.
$$
In the inner integral, $\displaystyle\int_0^t f_X(t)\,dx$, notice that as $x$ runs from $0$ to $t$, $f_X(t)$ does not change, since the variable $x$ does not appear within it. Since $f_X(t)$ does not depend on $x$, the inner integral is equal to
$$
f_X(t) \int_0^t 1\,dx.
$$
A: It's a change of order of integration.
\begin{align}
\int_{0}^\infty \int_{0}^x f_X(t)\operatorname d t\operatorname d x
& = \iint_{0 \leq x \leq t < \infty} f_X(t)\operatorname d t\operatorname d x
\\ & = \iint_{0 \leq x \leq t < \infty} f_X(t)\operatorname d x\operatorname d t
& \text{via Fubini's theorem}
\\ & = \int_{0}^{\infty} \int_{0}^t f_X(t)\operatorname d x\operatorname d t
\\ & = \int_{0}^{\infty} f_X(t) \int_{0}^t \operatorname d x\operatorname d t
\\ & = \int_{0}^{\infty} f_X(t) t\operatorname d t
\end{align}
