Given the density function$$f(x)=\begin{cases} \frac{x^2}{2}&\mbox{if }0\leq x<1\\
-x^2+3x-\frac{3}{2}&\mbox{if }1\leq x<2\\
\frac{(3-x)^2}{2}&\mbox{if }2\leq x<3\\
0&\mbox{else}\end{cases}$$Calculate $E(X)$
Can you please tell me if I do it correct? Because I would do it like that in the exam and I hope it's good:
$$E(X)=\int_{-\infty}^{\infty}xf(x) \;dx = \int_{0}^{1} x\frac{x^2}{2}\;dx + \int_{1}^{2} x(-x^2+3x-\frac{3}{2})\;dx + \int_{2}^{3} x\frac{(3-x)^2}{2}\;dx$$
I leave further calculation away to keep it short, just this part I'm not sure if it's fine like that?
Best Answer
Seek and you shall find. Anyways, yeah, you are doing that correctly.