TITLE: Explain why $E(X) = \int_0^\infty (1-F_X (t)) \, dt$ for every nonnegative random variable $X$
QUESTION [49 upvotes]: Let $X$ be a non-negative random variable and $F_{X}$ the corresponding CDF. Show,
  $$E(X) = \int_0^\infty (1-F_X (t)) \, dt$$
  when $X$ has : a) a discrete distribution, b) a continuous distribution.

I assumed that for the case of a continuous distribution, since $F_X (t) = \mathbb{P}(X\leq t)$, then $1-F_X (t) = 1- \mathbb{P}(X\leq t) = \mathbb{P}(X>  t)$. Although how useful integrating that is, I really have no idea.

REPLY [4 votes]: The function $x1[x>0]$ has derivative $1[x>0]$ everywhere except for $x=0$, so by a measurable version of the Fundamental Theorem of Calculus
$$
x1[x>0]=\int_0^{x}1[t>0]\ dt=\int_0^{\infty}1[x>t]\ dt,\qquad \forall x\in\mathbb R.
$$
Applying this identity to a non-negative random variable $X$ yields
$$
X=\int_0^{\infty}1[X>t]\ dt,\quad a.s.
$$
Taking expectations of both sides and using Fubini to interchange integrals,
$$
\mathbb EX=\int_0^{\infty}\mathbb P(X>t)\ dt.
$$