[Math] Finding the CDF of a piecewise PDF

integrationstatistics

So for my statistics class I am taking this semester we've been working on continuous random variables and we have one question that the teacher did not cover at all nor his notes, and it has to deal with piecewise functions.

I'm given the piecewise PDF f(x) = x + 1 for -1 < x < 0 and -x + 1 for 0 < x < 1.

I do know that to get from a PDF to a CDF you need to integrate the function which I did for both of these giving me x^2/2 + x and -x^2/2 + x. This question given in the book has the answer given in the back of the book and it has a + 1/2 on the end of both CDF functions.

My question is so I understand what is going here, where does that 1/2 come from in this question because the teacher never went over problems involving piecewise functions just single functions, and also the book doesn't ever mention piecewise functions either.

Best Answer

In general an indefinite integral should have a "$+C$" term. You actually want the cumulative distribution function $F(x)$ - the probability of seeing the value $x$ or below - to be the definite integral of the density function from $-\infty$ to $x$.

You want $F(-\infty)=0$ and $F(\infty)=1$ in general.

Since in your example the density is zero below $x=-1$ and above $x=1$, you want $F(-1)=0$ and $F(1)=1$ in this particular case. A continuous random variable random variable has a continuous cumulative distribution function, and in particular $F(x)$ needs to be be continuous where the piecewise densities meet, in this particular case at $x=0$. These together will give you the relevant constants.

For $-1 \le x \le 0$, you want $F(x)=\displaystyle \int_{y=-1}^x (y+1)\,dy$.

For $0 \lt x \le 1$, you want $F(x)=\displaystyle \int_{y=-1}^0 (y+1)\,dy +\int_{y=0}^x (-y+1)\,dy$.

Related Question