Prove that $E(X) = \int_{0}^{\infty} P(X>x)\,dx = \int_{0}^{\infty} (1-F_X(x))\,dx$.

Observe that for a continuous random variable, (well absolutely continuous to be rigorous):

$$\mathsf P(X> x) = \int_x^\infty f_X(y)\operatorname d y$$

Then taking the definite integral (if we can):

$$\int_0^\infty \mathsf P(X> x)\operatorname d x = \int_0^\infty \int_x^\infty f_X(y)\operatorname d y\operatorname d x$$

To swap the order of integration we use Tonelli's Theorem, since a probability density is strictly non-negative.

Observe that we are integrating over the domain where $0< x< \infty$ and $x< y< \infty$, which is to say $0<y<\infty$ and $0< x < y$.

$$\begin{align}\int_0^\infty \mathsf P(X> x)\operatorname d x = & ~ \iint_{0< x< y< \infty} f_X(y)\operatorname d (x,y) \\[1ex] = & ~ \int_0^\infty \int_0^y f_X(y)\operatorname d x\operatorname d y\end{align}$$

Then since $\int_0^y f_X(y)\operatorname d x = f_X(y) \int_0^y 1\operatorname d x = y~f_X(y)$ we have:

$$\begin{align}\int_0^\infty \mathsf P(X> x)\operatorname d x = & ~ \int_0^\infty y ~ f_X(y)\operatorname d y \\[1ex] = & ~ \mathsf E(X \mid X\geq 0)~\mathsf P(X\geq 0) \\[1ex] = & ~ \mathsf E(X) & \textsf{when $X$ is strictly positive} \end{align}$$

$\mathcal {QED}$


First note that \begin{align} P\{X>x\}&=E(1_{X>x})\\ &=\int_0^{\infty}1_{y>x}f(y)dy \end{align} Therefore \begin{align} \int_0^{\infty}P\{X>x\}dx&=\int_0^{\infty}\int_0^{\infty}1_{y>x}f(y)dydx\\ &=\int_0^{\infty}\int_0^{\infty}1_{y>x}f(y)dxdy\\ &=\int_0^{\infty}yf(y)dy\\ \end{align}


HINT

Since $1 - F_X(x) = P(X\geq x) = \int_x^\infty f_X(t) \,\mathrm{d}t$,

$$ \int_0^\infty \left( 1 - F_X(x) \right) \,\mathrm{d}x = \int_0^\infty P(X\geq x) \,\mathrm{d}x = \int_0^\infty \int_x^\infty f_X(t) \,\mathrm{d}t \mathrm{d}x $$

Then change the order of integration:

$$ = \int_0^\infty \int_0^t f_X(t) \,\mathrm{d}x \mathrm{d}t = \int_0^\infty \left[xf_X(t)\right]_0^t \,\mathrm{d}t = \int_0^\infty t f_X(t) \,\mathrm{d}t $$

Recognizing that $t$ is a dummy variable, or taking the simple substitution $t=x$ and $\mathrm{d}t = \mathrm{d}x$,

$$ = \int_0^\infty x f_X(x) \,\mathrm{d}x = \mathrm{E}(X) $$