Expectation of a mixed random variable given only the CDF
Solution 1:
Here's a careful derivation of the formula in Gautam Shenoy's answer:
If $X$ is a non-negative random variable, this well-known result: $$ \mathrm E(X)=\int_0^{+\infty}\mathrm P(X\gt t)\,\mathrm dt=\int_0^{+\infty}\mathrm P(X\geqslant t)\,\mathrm dt\tag1 $$ expresses the expectation of $X$ in terms of its CDF: $$ \mathrm E(X)=\int_0^{+\infty}[1 - F(t)]\,\mathrm dt\tag2 $$ To extend (2) to the general case where $X$ may take negative values, we can write $$E(X)=E(X^+)-E(X^-)\tag3$$ where the positive part and negative part of $X$ are defined by $$ X^+:=\begin{cases} X& \text{if $X>0$}\\ 0&\text{otherwise}\\ \end{cases}\tag4 $$ and $$ X^-:=\begin{cases} -X& \text{if $X<0$}\\ 0&\text{otherwise}\\ \end{cases}.\tag5 $$ Since both $X^+$ and $X^-$ are nonnegative, we can apply (1). Observe that for every $t>0$ $$ P(X^+>t)=P(X>t)=1-F(t)\tag6 $$ and $$P(X^-\ge t)=P(X\le -t)=F(-t).\tag7$$ Plugging these into (1) and using (3) gives $$ E(X)=\int_0^\infty[1-F(t)]dt-\int_0^\infty F(-t)dt.\tag8 $$ After a change of variable in the second integral we obtain the equivalent $$ E(X)=\int_0^\infty[1-F(t)]dt-\int_{-\infty}^0 F(t)dt.\tag9 $$
Solution 2:
Use $$ E[X] = \int_0^\infty (1-F(x))dx - \int_{-\infty}^0 F(x)dx$$