$$F(x)= \begin{cases} \ 0 & \text{if $\ \ \ x<0$}\\ \ \dfrac{4}{9}& \text { if $\ \ \ 0 \le x<1$}\\ \ \dfrac{8}{9}& \text { if $\ \ \ 1 \le x<2$} \\ \ 1& \text { if $\ \ \ x\ge 2$} \end{cases} $$
I am trying to find out expectation using this $$\mathbb{E}[X]=\int_0^\infty (1-F(x)) \mathrm{d}x$$ If I replace integral with the sum, I found this expectation:
$$\mathbb{E}[X]=(0)\left(1-\dfrac{4}{9}\right)+(1)\left(1-\dfrac{8}{9}\right)+ (2)(1-1)=\dfrac{1}{9}$$
But when I calculate via $$\mathbb{E}[X]=\sum x\Pr(X=x)=0\cdot \dfrac{4}{9}+1\cdot \dfrac{4}{9}+2\cdot \dfrac{1}{9}=\dfrac{6}{9}=\dfrac{2}{3}$$
Why am I getting different answer in first method I did. I should be getting $\dfrac{2}{3}$. Can anyone point out my mistake ?
$$ \mathbb E(X)=\int\limits_0^\infty (1-F(x)) dx = \int\limits_0^1 \left(1-\frac49\right)dx + \int\limits_1^2 \left(1-\frac89\right)dx = \frac59 \cdot 1+ \frac19\cdot 1 = \frac23. $$ You can also draw a graph of $F(x)$ and find the area above the positive semi-axis between this function and the function equal to one.