Calculate the expectation of a random variable given its cdf The cdf of a random variable $X$ is given by the following.
\[
F_X(x) = \begin{cases} 0 & x < 0\\\\ \frac x2 & x \in [0,1)\\\\ \frac 23 & x \in [1,2)\\\\
   \frac{11}{12} & x \in [2,3) \\\\ 1 & x \ge 3
\end{cases}
\]
How do I calculate the expectation of the random variable $X$? 
 A: $$\int_0^\infty (1 - F(x))\ dx$$
A: You can come up with a piecewise defined density function by differentiating, but that fails to account for the jump discontinuities at $x=1$, $x=2$, and $x=3$.  You get
$$
f(x) = 1/2\text{ if }1<x<2\text{ and }f(x)=0\text{ elsewhere}.
$$
Calling the random variable (capital) $X$, we then have
$$
\begin{cases}
\Pr(X\in A) = \int_A \frac12\  dx & \text{if }A\subseteq[0,1), \\[8pt]
\Pr(X=1) = 1/6, \\[8pt]
\Pr(X=2) = 1/4, \\[8pt]
\Pr(X=3) = 1/12.
\end{cases}
$$
The expected value is then
$$
\int_0^1 x\frac12\, dx + 1\cdot\frac16 + 2\cdot\frac14+3\cdot\frac{1}{12}.
$$
This is somewhat pedestrian, but it has this advantage over Robert Israel's answer: the method still works even for random variables that can be negative.
A: There is another, definitely less good way, to find the expectation. Let us analyze the distribution of the random variable $X$. The part before $0$ is harmless. 
For $0\le x\lt 1$, the cumulative distribution function is $x/2$, nice and familiar, the density function is the derivative of the the cdf, which is $1/2$.
At $1$, and all the way up to but not including $2$, the cdf is $2/3$. So there is a sudden jump at $x=1$. As we approach $1$ from the left, the cdf approaches $1/2$, but all of a sudden it is $2/3$ at $1$, and then stays at that all the way to, but not including $2$. What that means is that there is a discrete "weight" of $2/3-1/2$ at $x=1$: $\Pr(X=1)=2/3-1/2=1/6$.
The cdf takes another sudden jump to $11/12$ at $2$. That means we have a weight of $11/12-2/3$, that is, $3/12$, at $x=2$.
Finally, there is another weight of $1/12$ at $x=3$.
To sum up, this is a mixed continuous-discrete situation: there is a continuous uniform distribution, density $1/2$, between $0$ and $1$. In addition, $\Pr(X=1)=1/6$, $\Pr(X=2)=3/12$, and $\Pr(X=3)=1/12$. The moment about the origin (mean) is therefore 
$$\int_0^1 x\cdot\frac{1}{2}\,dx+ 1\cdot\frac{1}{6}+2\cdot \frac{3}{12}+3\cdot \frac{1}{12}.$$
I think this simplifies to $\dfrac{7}{6}$. You might want to compare that with the result you get from doing it the full integration way. The latter approach is the one you should become comfortable with.
