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.


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.$$


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$.