# Finding the CDF from a PDF with absolute value function

1. Nov 27, 2013

### TeenieBopper

1. The problem statement, all variables and given/known data
Find the CDF of $$f(x) = |\frac{x}{4}| if -2<x<2 \\ 0 otherwise$$

2. Relevant equations

3. The attempt at a solution

I have to integrate the pdf and to do so, I have to split it into two parts

$$\int_{-x}^{0}\frac{-t}{4}dt + \int_{0}{x}\frac{t}{4}dt$$

integrating I get $$\frac{x^2}{8} + \frac{x^2}{8} = \frac{x^2}{4}$$

This isn't a strictly increasing function, which is a requirement to be a CDF. So I need to break it into cases. This is where I'm running into trouble (sorry, I don't know if/how to use cases environment here).
F(x)
$$0 if x < -2 \\ 1-\frac{x^2}{4} if -2<x<0 \\ some equation if 0<x<2 \\ 1 if x>2$$

I know that the CDF must have a value of .5 if X=0, but I'm not sure how to set up the rest of the cases so that F(0)=.5 and F(2)=1

Am I allowed to keep the two integrals from above "split"? Because if I am, then the following should work:

F(x)=
$$0 x<-2 \\ \frac{1}{2} -\frac{x^2}{8} if -2<x<0 \\ \frac{1}{2} + \frac{x^2}{8} if 0<x<2 \\ 1 if x > 2$$

Am I just overthinking it, or can I just use that for the CDF?

Last edited: Nov 27, 2013
2. Nov 27, 2013

### vela

Staff Emeritus
Your limits are wrong. You want
$$F(x) = \int_{-\infty}^x f(x)\,dx = P(X \le x)$$

3. Nov 27, 2013

### haruspex

The CDF F(x) is by definition the integral of the PDF from -∞ to x. So I'm not sure what the question is asking for.

Edit: I see you've changed the problem statement. It makes more sense now.

Last edited: Nov 27, 2013
4. Nov 27, 2013

### TeenieBopper

I changed the pdf so it should be technically correct now

So, because it's an absolute value function, it should be:

$$\int_{-2}^{x}\frac{-x}{4} dt + \int_{0}^{x}\frac{x}{4}dt$$? Because then I get $$F(x) = \frac{x^2}{4} - \frac{1}{2}$$ which again, isn't monotone increasing.

Ultimately, my I need to use the inversion method to generate observations from f(x), but in order to do that, I need the CDF.

5. Nov 27, 2013

### vela

Staff Emeritus
No, that's not correct. You need to look at different cases. It may help to sketch the PDF and the region of integration for the various cases.

6. Nov 27, 2013

### LCKurtz

Those $x$'s should be $t$'s, and those two integrals, separately, will be part of your work. By as vela points out, you aren't setting up the problem correctly. Consider the cases $-2<x<0$ and $0<x<2$ separately when considering the integral $\int_{-\infty}^xf(t)~dt$.

7. Nov 27, 2013

### TeenieBopper

It's an absolute value function, so if I graph it, it's essentially two triangles, each with a point at 0,0 and then vertical edges at x=-2 and x=2. So there's two cases, -2<x<0 and 0<x<2, that I look at seperately.

Looking at the first case, the integral is

$$\int_{-2}^{x} \frac{-t}{4} dt = \frac{t^2}{8} |_{-2}^x = \frac{x^2}{8} - \frac{1}{2}$$

But this can't be part of a CDF because it's a decreasing function on (-2, 0), which is why I thought the function for the CDF in this case was $$\frac{1}{2} - \frac{x^2}{8}$$

Looking at the case 0<x<2, the integral is

$$\int_{0}^{x} \frac{t}{4}dt = \frac{t^2}{8} |_{0}^{x} = \frac{x^2}{8}$$

Now, this is increasing on (0, 2), but the value at 2 is only 1/2, which is why I thought I could add 1/2 to this case of the CDF (which is the area under the curve from the first case), making it $$\frac{1}{2} + \frac{x^2}{8}$$

This would make the complete cdf

F(x)=
0 if x<-2
$$\frac{1}{2} -\frac{x^2}{8}$$ if -2<x<0
$$\frac{1}{2} + \frac{x^2}{8}$$ if 0<x<2
1 if x > 2

I don't understand why this isn't it.

8. Nov 27, 2013

### Office_Shredder

Staff Emeritus
What you wrote down is the CDF, you just made a couple mistakes. In calculating the CDF for the -2<x<0 part, you are integrating negative t/4, and the negative sign simply disappeared. When doing the 0<x<2 part, remember what you are calculating is
$$\int_{-2}^{x} f(t) dt = \int_{-2}^{0} f(t) dt + \int_{0}^{x} f(t) dt.$$

You know from your previous calculation that
$$\int_{-2}^{0} f(t) dt = 1/2,$$
and this is exactly the 1/2 that you are missing.

9. Nov 27, 2013

### Ray Vickson

If you plot f(t) and recognize that F(x) = area under the f(t)-curve to the left of t=x, you can see immediately that F(x) = 0 if x < -2 and F(x) = 1 if x > +2. For -2 < x < 0, the area to the left of x is the whole area from t=-2 to t=0, minus the area from t = x to t = 0. So, if you know how to compute areas of triangles you are home free. For 0 < x < 2 you have F(x) = F(0) + area between t=0 and t=x, and that is easy, too.