TITLE: Tail sum for expectation
QUESTION [16 upvotes]: In Pitman's Probability, the tail sum formula for expectation is introduced for a nonnegative (0,1,...) discrete random variable $X$:
$$E(X) = \sum_{i=0}^\infty P(X > i).$$

I wonder if there is a similar formula for nonnegative continuous
random variable $X$:
$$E(X) = \int_0^\infty P(X > x) dx?$$
If no, are there some conditions for it to hold? And how can it be
proved?
Here is my thought:
If the cdf $F$ of $X$ is bijective, then $X=F^{-1}(U)$ for some
random variable $U$ uniformly distributed over $[0,1)$. So $$E(X) =
    \int_0^1 F^{-1}(u) du.$$
To prove the tail sum formula, it suffices to prove $$\int_0^1
    F^{-1}(u) du = \int_0^\infty P(X > x) dx.$$ But I am stuck here. 
What's more, is the condition that the cdf $F$ of $X$ is bijective
really necessary for tail sum formula to hold?
Can tail sum formula be generalized to a random variable that is not
necessarily nonnegative?

Thanks!

REPLY [2 votes]: @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.)