# Expected value of $f(x)=\vert x \vert/10$ where $-2\leq x\leq4$

Let x be a continuous random variable with density function

$f(x) \begin{cases} \frac{\vert x \vert}{10} & for -2 \le x \le 4 \\ 0 & \text{otherwise} \end{cases}$

Calculate the expected value of X

Split the integral at $0$ and integrate on $[-2,0]$ and $[0,4]$

$\int_{-2}^0 \frac{-x}{10}dx$ + $\int_{0}^4 \frac{x}{10}dx$

integrating gives us:

$\frac{-x^2}{20} \vert_{-2}^0$ + $\frac{x^2}{20} \vert_0^4$

which gives us $\frac{3}{5}$

However the answer sheet I am looking at says that the answer is $\int_{-2}^0 \frac{-x^2}{10}dx$ + $\int_0^4 \frac{x^2}{10}dx$

and comes out to

$\frac{-x^3}{30} \vert_{-2}^0$ + $\frac{x^3}{30} \vert_{0}^4$ which comes out to $\frac{28}{15}$

Can someone tell me if the answer that they are giving is a mistake because where in the heck do you jump from the original function to be integrated being $x$ to $x^2$. This has to be a mistake right? Or am I missing something?

If $f(x)$ is the density function of the random variable $X$ then the expected value is
$$\mathbb{E}[X] = \int \color{red}{x}~f(x)~{\rm d}x$$
You are missing the factor $\color{red}{x}$ in your work