$ \ F(x) = \begin{cases} 0 & x < -2\\ .2& -2 \le x< 0 \\ .5 & 0 \le x <2.2 &\\ .6 & 2.2 \le x <3 \\.9&3 \le x<4 \\ 1 & x\ge4\end{cases}$
Find $E(X)$
I am trying to use this formula $E(X)=\sum_{x>0}(1-F(x))-\sum_{x<0}(F(x))$
$\bigg((1-.5)+(1-.6)+(1-.9)+(1-1)\bigg)-\bigg(.2\bigg)=.5+.4+.1-.2=.8$
But this is wrong, answer given is different. Can anyone point out my mistake?
That formula only works when your random variable is confined to the integers, which yours is not (since it can be $2.2$ with positive probability). Instead you can use the formula $E[X]=\int_0^\infty (1-F(x)) dx - \int_{-\infty}^0 F(x) dx$. This formula holds for general $X$ provided that the subtraction makes sense (i.e. you don't have $\infty-\infty$). The formula you wrote is obtained if you split the integrals into the intervals $[n,n+1)$ for integers $n$, provided that $F$ is always constant on such intervals (which again is not the case here).
You can also just write down the PMF and use the usual sum over all possible values. The PMF will be $p(x)=\lim_{y \to x^+} F(x)-\lim_{y \to x^-} F(x)$ for all $x$ where $F$ has a jump.