# Thread: c.d.f. of a random variable, given pdf

1. ## c.d.f. of a random variable, given pdf

pdf is given by

$\displaystyle f(x) = 2-4|x| if -1/2 < x < 1/2$ and $\displaystyle 0$ otherwise

I cant do the integral of $\displaystyle 2-4|x|$ so I am going to make 2 cases, $\displaystyle x < 0$ and $\displaystyle x > 0.$

$\displaystyle If x < 0 , f(x) = 2+4x$ for $\displaystyle -1/2 < x < 0$

So we look at $\displaystyle \int_{x}^{0} 2+4t \text{d}t = -2x(x+1)$

$\displaystyle If x > 0 , f(x) = 2x-4x$for $\displaystyle 0 < x < 1/2$

So we look at $\displaystyle \int_{0}^{x} 2-4t \text{d}t = -2x(x-1)$

So I figure the cdf should be

$\displaystyle F_X(x) =$

$\displaystyle 0$ if $\displaystyle x \leq -1/2$

$\displaystyle -2x(x+1)$ if $\displaystyle -1/2 < x < 0$

$\displaystyle -2x(x-1) + \int_{-1/2}^{0} 2+4t \text{d}t = -2x(x-1) + 1/2$
if $\displaystyle 0 \leq x < 1/2$

$\displaystyle 1$ if $\displaystyle x \geq 1/2$

So i think is make sense to put $\displaystyle 0$ with the positive case. Since the adding of the $\displaystyle 1/2$ captures all the probabilities for negative values. However I think the function for $\displaystyle -1/2 < x < 0$ is wrong. Lower numbers are giving me higher probabilities than numbers close to $\displaystyle 0$. So something must be wrong.

2. Originally Posted by Jame
pdf is given by

$\displaystyle f(x) = 2-4|x| if -1/2 < x < 1/2$ and $\displaystyle 0$ otherwise

I cant do the integral of $\displaystyle 2-4|x|$ so I am going to make 2 cases, $\displaystyle x < 0$ and $\displaystyle x > 0.$

$\displaystyle If x < 0 , f(x) = 2+4x$ for $\displaystyle -1/2 < x < 0$

So we look at $\displaystyle \int_{x}^{0} 2+4t \text{d}t = -2x(x+1)$

$\displaystyle If x > 0 , f(x) = 2x-4x$for $\displaystyle 0 < x < 1/2$

So we look at $\displaystyle \int_{0}^{x} 2-4t \text{d}t = -2x(x-1)$

So I figure the cdf should be

$\displaystyle F_X(x) =$

$\displaystyle 0$ if $\displaystyle x \leq -1/2$

$\displaystyle -2x(x+1)$ if $\displaystyle -1/2 < x < 0$

$\displaystyle -2x(x-1) + \int_{-1/2}^{0} 2+4t \text{d}t = -2x(x-1) + 1/2$
if $\displaystyle 0 \leq x < 1/2$

$\displaystyle 1$ if $\displaystyle x \geq 1/2$

So i think is make sense to put $\displaystyle 0$ with the positive case. Since the adding of the $\displaystyle 1/2$ captures all the probabilities for negative values. However I think the function for $\displaystyle -1/2 < x < 0$ is wrong. Lower numbers are giving me higher probabilities than numbers close to $\displaystyle 0$. So something must be wrong.
It should be apparent that:

Case 1: $\displaystyle x < -\frac{1}{2}$. $\displaystyle \displaystyle F(x) = 0$.

Case 2: $\displaystyle -\frac{1}{2} \leq x \leq 0$. $\displaystyle \displaystyle F(x) = \int_{-1/2}^{x} (2 + 4t) \, dt$.

Case 3: $\displaystyle 0 < x \leq \frac{1}{2}$. $\displaystyle \displaystyle F(x) = \frac{1}{2} + \int_{0}^{x} (2 - 4t) \, dt$.

Case 4: $\displaystyle x > \frac{1}{2}$. $\displaystyle \displaystyle F(x) = 1$.

I got that the expected value,

$\displaystyle E[X] = \int_{-1/2}^{0} x(2+4x) \; \text{d}x + \int_{0}^{1/2} x(2-4x) \; \text{d}x = 0$

Can I not break up the function to calculate the expected value?

4. Originally Posted by Jame
$\displaystyle E[X] = \int_{-1/2}^{0} x(2+4x) \; \text{d}x + \int_{0}^{1/2} x(2-4x) \; \text{d}x = 0$
Yes you can, which is what you appear to have done. But I would have used the fact that f(x) is even and hence xf(x) is odd to get $\displaystyle \displaystyle \int_{-1/2}^{1/2} x f(x) \, dx = 0$.