Calculating a proper probability density function on piecewise function

33 Views Asked by At

I need to prove that this equation is a proper probability density function, that is that it's equal to 1.

$$f(x) = 1 - |x|, for -1 \le x \le 1$$

So I tried to compute the integral $$\int_{-1}^{1}1-|x|dx = \begin{cases} \int_{0}^{1}1-xdx, & \text{x >= 0} \\ \int_{-1}^{0}1-(-x)dx, & \text{x < 0} \end{cases}$$

$$=\begin{cases} [1 - \frac{x^2}{2}]_0^1 \\ [1 + \frac{x^2}{2}]_{-1}^0 \end{cases}$$ $$=\begin{cases} [(1 - \frac{1^2}{2}) - (1 - \frac{0}{2})] \\ [(1 + \frac{0^2}{2}) - (1 + \frac{-1^2}{2})] \end{cases}$$ $$=\begin{cases} [0.5 - 1] \\ [1 - 1.5] \end{cases}$$ $$=\begin{cases} -0.5 \\ -0.5 \end{cases}$$

Adding these two answers together I get -1, not 1. What did I do wrong?

2

There are 2 best solutions below

0
On BEST ANSWER

An anti-derivative of $1-x$ is $x-\frac {x^{2}} 2$. You wrote $1-\frac {x^{2}} 2$.

You should get $\int_0^{1}(1-x)dx=\frac 1 2$ and $\int_{-1}^{0}(1-x)dx=\frac 1 2$.

0
On

Does this help... the plot of $f(x)$?

enter image description here