Tail sum for expectation
Solution 1:
This is Fubini theorem for nonnegative functions/sums. If $x$ is a nonnegative integer,
$$ x=\sum_{i=0}^{+\infty}[x\gt i]. $$
Likewise, if $x$ is a nonnegative real number,
$$ x=\int_{0}^{+\infty}[x\gt t]\mathrm dt,\qquad x=\int_{0}^{+\infty}[x\geqslant t]\mathrm dt. $$
Then one integrates both sides of the relevant identity with respect to the distribution $\mathrm P_X$ of $X$ and one uses Fubini theorem to change the order of the summation/integral and of the expectation.
For example, the second identity yields $$ \mathbb E(X)=\int_\Omega X\ \mathrm d\mathbb P=\int_\Omega \int_{0}^{+\infty}[X\gt t]\mathrm dt\ \mathrm d\mathbb P=\int_{0}^{+\infty}\int_\Omega [X\gt t]\mathrm d\mathbb P\ \mathrm dt $$ that is,
$$\mathbb E(X)=\int_{0}^{+\infty}\mathbb P(X\gt t)\ \mathrm dt. $$
Likewise, the first identity yields $$ \mathbb E(X)=\int_\Omega X\ \mathrm d\mathbb P=\int_\Omega\ \sum\limits_{i=0}^{+\infty}[X\gt i]\ \mathrm d\mathbb P=\sum\limits_{i=0}^{+\infty}\ \int_\Omega[X\gt i]\ \mathrm d\mathbb P $$ that is,
$$\mathbb E(X)=\sum\limits_{i=0}^{+\infty}\mathbb P(X\gt i). $$
Solution 2:
This is integration by parts. Take $X\geq 0$, and call its distribution function $F$. Let $g$ be an increasing differentiable function with $g(0)=0$.
$$\begin{align*} \mathbb{E}[g(X)]&=\int_0^\infty g(t) dF(t) \\ &= \int_0^\infty -g(t) d(1-F(t)) \\ &= [-g(t)(1-F(t))]^\infty_0 - \int_0^\infty 1-F(t)d(-g(t)) \\ &= \int_0^\infty g'(t)\mathbb{P}[X>t]dt \end{align*}$$
This reduces to what you want when $g(X)=X$.
One way we could compute $\mathbb{E}[X]$ for general $X$ would be to compute $\mathbb{E}[X^+]$ and $\mathbb{E}[X^-]$ in this way and then take the difference, where $X^+=\max(X,0)$ and $X^-=\max(-X,0)$.
Justification of integration by parts: The integration by parts works when $g(X)$ is integrable, since, by dominated convergence, $$\begin{align} \limsup_x g(x)\mathbb{P}[X>x] &\le \limsup_x\mathbb{E}[g(X)\mathbf{1}(X>x)]\\ &= \mathbb{E}[\limsup_x g(X)\mathbf{1}(X>x)]\\ &= 0. \end{align}$$
Solution 3:
First we prove that for $X \geq 0$ $$EX= \int_{0}^{\infty}P(X > t)dt.$$ We apply Fubini's theorem. Our product measure will be a product of the distribution of $X$ and Lebesgue measure. So $$\int_{0}^{\infty}P(X>t)dt = \int_0^{\infty}\left( \int_{t}^{\infty} \nu_X(ds)\right)dt=\int_{\mathbb{R}}\left( \int_{0}^{\infty}\textbf{1}_{[0,\infty)}(t)\textbf{1}_{(t,\infty)}(s)\nu_X(ds)\right)dt=$$ $$=\int_{0}^{\infty}\left(\int_0^s dt \right) \nu_X(ds)= \int_{0}^{\infty}s \nu_X(ds)=\int_{\mathbb{R}}s\nu_X(ds)=EX$$
But, you want to have $EX=\int_{0}^{\infty}P(X \geq t)dt.$
Applying what we have already proved, it is enough to show that $\int_{0}^{\infty}P(X=t)dt=0$.
Solution 4:
@Did gave a great answer, and while I'm thinking about it I want to record a similar answer using slightly different notation in the case where the cumulative density function $F$ is differentiable.
In this case, \begin{align} \mathbb E(X) &= \int_0^\infty x F'(x) \, dx \\ &= \int_0^\infty \int_0^\infty [x \geq t] \, dt \,F'(x) \, dx \\ &= \int_0^\infty \int_0^\infty [x \geq t] F'(x) \, dt \, dx \\ &= \int_0^\infty \int_0^\infty [x \geq t] F'(x) \, dx \, dt \quad \text{(Fubini's theorem)}\\ &= \int_0^\infty \int_t^\infty F'(x) \, dx \, dt \\ &= \int_0^\infty 1 - F(t) \, dt. \end{align}
(The quantity $[x \geq t]$ is equal to $1$ if $x \geq t$ and $0$ otherwise.)