4
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ You are calculating the antiderivative instead of the integral, the area under the off to the left of $x$ $\endgroup$ Apr 11 '15 at 20:50
  • $\begingroup$ So the 1/2 that is added at the end is from doing the integral of x+1 from -1 to 0 and -x+1 from 0 to 1? $\endgroup$
    – Ramirez77
    Apr 11 '15 at 20:56
  • $\begingroup$ You ask "So the 1/2 that is added at the end is from doing the integral of x+1 from -1 to 0 and -x+1 from 0 to 1?" Not quite. You need to find area under the pdf to the left of $x$. Drawing a sketch of the pdf and marking the relevant areas is a big help in such problems. For $x$ between $-1$ and $0$, we need the area of a right triangle with base and altitude of length $(x-(-1))=x+1$. So, $F(x)=\frac 12(x+1)^2$ for $x\in(-1.0)$. For $x\in(0,1)$, we need $1$ minus the area of a right triangle with base and altitude $(1-x)$. (Figure out why minus etc). So, $F(x)=1 - \frac 12(1-x)^2$. $\endgroup$ Apr 12 '15 at 20:18
4
$\begingroup$

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$.

$\endgroup$
1
  • $\begingroup$ Oh okay, that makes a whole lot of sense now. Thank you very much. $\endgroup$
    – Ramirez77
    Apr 11 '15 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.