If X is a non-negative continuous random variable, show that $E[X]=\int_0^\infty (1-F(x)) dx$ There is a hint to solve this by using integration by parts. So I have $$ u = x \space \mbox{then} \space u'=1$$
$$v' = F(x) -1 \space \mbox{then} \space = ? $$
QUESTION:
What is $v'$ ? 
What is the theoretical idea behind this? I would not have thought of this approach without the hint. 
 A: Observe that for a continuous random variable, (well absolutely continuous to be rigorous):
$$\mathsf P(X> x) = \int_x^\infty f_X(y)\operatorname d y$$
Then taking the definite integral (if we can):
$$\int_0^\infty \mathsf P(X> x)\operatorname d x = \int_0^\infty \int_x^\infty f_X(y)\operatorname d y\operatorname d x$$
Observe that we are integrating over the domain where $0< x< \infty$ and $x< y< \infty$, which is to say $0<y<\infty$ and $0< x < y$.
$$\begin{align}\int_0^\infty \mathsf P(X> x)\operatorname d x = & ~ \iint_{0< x< y< \infty} f_X(y)\operatorname d (x,y)
\\[1ex] = & ~ \int_0^\infty \int_0^y f_X(y)\operatorname d x\operatorname d y\end{align}$$
Then since $\int_0^y f_X(y)\operatorname d x = f_X(y) \int_0^y 1\operatorname d x = y~f_X(y)$ we have:
$$\begin{align}\int_0^\infty \mathsf P(X> x)\operatorname d x = & ~ \int_0^\infty y ~ f_X(y)\operatorname d y \\[1ex] = & ~ \mathsf E(X \mid X\geq 0)~\mathsf P(X\geq 0) \\[1ex] = & ~ \mathsf E(X) & \textsf{when $X$ is strictly positive} \end{align}$$
A: You can accomplish this with an interchange of integral signs as follows.
$$\int_0^\infty (1 - F(x))\, dx  = \int_0^\infty\int_x^\infty dF(t)\, dx
= \int_0^\infty \int_0^x dt\, dF(x) = \int_0^\infty  x\, dF(x)$$
A: In the continuous case you want to go the other way around, differentiate $1-F$ to into $-f$ and then the integration of $1$ creates the factor of $x$ that you want to see. But this works only in the continuous case.
The standard way to do this in the general case is to use Fubini's theorem, $1-F(x)=P(X>x)=\int_x^\infty dF(y)$. So now you have $\int_0^\infty \int_x^\infty dF(y) dx$, and interchanging the order of integration achieves the desired result.
