Show that $E(X)=\int_{0}^{\infty}P(X\ge x)\,dx$ for non-negative random variable $X$ 
Show that for a non-negative random variable $X$,
  $$\mathbb E(X)=\int_0^\infty \mathbb P(X\ge x) \, dx.$$

I started with 
$$\mathbb E(X)=\int_0^\infty x \, dF(x)=\int_0^\infty \int_0^x dt\,dF(x).$$
This is my try. 
 A: Integrate the LHS and the RHS of the pointwise identity
$$
X=\int_0^X\mathrm dx=\int_0^\infty\mathbf 1_{X\geqslant x}\,\mathrm dx.
$$
This shows that the desired formula for $E[X]$ holds irrespectively of the hypothesis that $X$ is discrete or continuous or neither discrete nor continuous, as soon as $X\geqslant0$ almost surely, and that two formulas are available, namely,
$$
E[X]=\int_0^\infty P[X\geqslant x]\,\mathrm dx=\int_0^\infty P[X\gt x]\,\mathrm dx.$$
A: Use integration by parts. Let $f(x)$ denote the probability density of $X$.
Define $F(x)=P(X\geq x)=\int_x^\infty f(z)dz$, then $f(x)=-F'(x)$ 
$$
E(x)=\int_0^\infty x f(x) \,dx= -xF(x)\vert_0^\infty+\int_0^\infty F(x)\,dx
= \int_0^\infty F(x)\,dx
$$
The other way is 
$$
\int_0^\infty P(X\geq x) \,dx=\int_0^\infty \int_x^\infty f(z)\,dz \,dx
=\int_0^\infty \int_0^\infty f(z) I\{z\geq x\} \,dz \,dx
=\int_0^\infty  f(z) \,dz \int_0^\infty I\{z\geq x\} \,dx
=\int_0^\infty  z f(z) \,dz
=E(x)
$$
where $I\{z\geq x\}$ is indicator function, i.e. $I\{z\geq x\}=1$ if $z\geq x$; Otherwise, $I\{z\geq x\}=0$.
A: If $\Pr(X>0)= 1$ then $$ \begin{align} X & = \int_0^\infty \boldsymbol{1}_{X\,>\,c}(c) \, dc \\  \\ \text{and therefore } \operatorname{E}(X) & = \operatorname{E}\int_0^\infty \boldsymbol{1}_{X\,>\,c} (c) \,dc \\  \\ & = \int_0^\infty \operatorname{E}(\boldsymbol{1}_{X\,>\,c} (c)) \, dc \longleftarrow \text{How is this step justified? See below.} \\  \\ & = \int_0^\infty \Pr(X>c)\,dc. \end{align} $$ To justify the step mentioned above, I would cite Tonelli's theorem, which justifies interchanging the order of integration when the function being integrated is non-negative, regardless of whether the value of the integral is finite.
