Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

So I have this PDF: $$ f(x)= \begin{cases} x + 3 & \text{ for } -3 \leq x < -2\\ 3 - x & \text{ for } 2 \leq x < 3\\ 0 & \text{ otherwise} \end{cases} $$

To make this a CDF, I have integrated the PDF from $-\infty$ to some value, $x$.

$$ F(x)= \begin{cases} \frac{x^2}{2} + 3x + \frac{9}{2} & \text{ for } -3 \leq x <-2\\ \frac{1}{2} & \text{ for } -2 \leq x<2\\ \frac{-x^2}{2} + 3x + \frac{7}{2} & \text{ for } 2 \leq x<3 \end{cases} $$

My friend argues that the first term in this CDF which is $(x^2/2 + 3x + 9/2)$ should actually be $(x^2/2 + 3x)$. But isn't this impossible? At $x = -3$, the CDF must be $0$, am I correct?. This is only true in the case where the first term is $(x^2/2 + 3x + 9/2)$.

If someone could shed light on this topic, that would be much appreciated.

share|improve this question
You don't integrate all the way to $\infty$ you integrate up to a fixed (but arbitrary) value, $y$. –  Adam Hughes Jun 30 at 3:57
yes, I have done just that for my first two terms. can someone confirm, or discuss this question further? –  baba Jun 30 at 4:00
I've upgraded my comment to an answer below. –  Adam Hughes Jun 30 at 4:10

6 Answers 6

up vote 3 down vote accepted

$ f(x) = \begin{cases} 0 &, \phantom{-3 \leq {}}x< -3 \\ x+3 &, -3 \leq x \leq -2 \\ 0 &, -2 \leq x \leq \phantom{-{}}2 \\ 3-x &, \phantom{-{}}2 \leq x \leq \phantom{-{}}3 \\ 0 &, \phantom{-{}}3 \leq x\end{cases}$

\begin{align} F(x) = \int_{-\infty}^x f(t) \,\mathrm{d}t &= \begin{cases} 0 &, \phantom{-3 \leq {}}x< -3 \\ 0+\int_{-3}^x t+3 \,\mathrm{d}t &, -3 \leq x \leq -2 \\ 0+\int_{-3}^{-2} t+3 \,\mathrm{d}t + 0&, -2 \leq x \leq \phantom{-{}}2 \\ 0+\int_{-3}^{-2} t+3 \,\mathrm{d}t + \int_{2}^x 3-t \,\mathrm{d}t&, \phantom{-{}}2 \leq x \leq \phantom{-{}}3 \\ 0+\int_{-3}^{-2} t+3 \,\mathrm{d}t + \int_{2}^3 3-t \,\mathrm{d}t + 0 &, \phantom{-{}}3 \leq x\end{cases} \\ &= \begin{cases} 0 &, \phantom{-3 \leq {}}x< -3 \\ 0+\frac{x^2+6x+9}{2} &, -3 \leq x \leq -2 \\ 0+\frac{1}{2} &, -2 \leq x \leq \phantom{-{}}2 \\ 0+\frac{1}{2} + \frac{-x^2+6x-8}{2}&, \phantom{-{}}2 \leq x \leq \phantom{-{}}3 \\ 0+\frac{1}{2} + \frac{1}{2} + 0 &, \phantom{-{}}3 \leq x\end{cases} \end{align}

As you can see $F(-3) = 0$ because $\frac{9-18+9}{2} = 0$. Your argument is correct that the CDF must increase from zero (starting) at $-3$.

share|improve this answer
I see that the OP's $f$ has changed... Editing. –  Eric Towers Jun 30 at 4:23
3-x for 2≤x≤3, not −2≤x≤3 as you have stated. –  baba Jun 30 at 4:26
@baba: So in the three minutes from my comment and start to re-edit until your comment, you didn't bother to read my comment? Also, updated for the changed OP. –  Eric Towers Jun 30 at 4:31
Oh, I'm really sorry. I wasn't paying attention. Thank you for the answer, it is well written. –  baba Jun 30 at 4:36

Hint: integrate $ 3-x$. Say, integral is $f(x)$. Plug in $f(3)=1$ to get the value of constant

share|improve this answer

Strictly speaking the CDF should be defined for all $x\in\Bbb R$. If $x\le-3$ we have $$F(x)=\int_{-\infty}^x f(t)\,dt=\int_{-\infty}^x 0\,dt=0\ .$$ If $-3<x<-2$ then $$F(x)=\int_{-\infty}^x f(t)\,dt =\int_{-\infty}^{-3} 0\,dt+\int_{-3}^x t+3\,dt =\frac{1}{2}(x+3)^2$$ (which in fact is the answer you have already, but it's simpler this way). For $-2\le x\le2$ we get $F(x)=\frac{1}{2}$ as you have already. For $2<x<3$ we obtain $$F(x)=\int_{-\infty}^x f(t)\,dt =\int_{-\infty}^2 f(t)\,dt+\int_2^x f(t)\,dt =\frac{1}{2}+\int_2^x (3-t)\,dt=1-\frac{1}{2}(3-x)^2\ .$$ Finally, if $x\ge 3$ then $F(x)=1$.

As a check, note that you should have $F(x)$ always increasing and $$\lim_{x\to-\infty} F(x)=0\quad\hbox{and}\quad \lim_{x\to\infty} F(x)=1\ .$$

share|improve this answer

The cdf $F(x)$ is given by $$F(x) =\begin{cases} 0 & \text{ for } x <-3\\ \int_{-3}^{x}(t+3) \, dt & \text{ for } -3 \leq x <-2\\ \frac{1}{2} & \text{ for } -2 \leq x <2\\ \frac{1}{2}+\int_{-2}^{x}(3-t) \, dt & \text{ for } 2 \leq x <3\\ 1 & \text{ otherwsie} \end{cases} $$ My suggestion is to plot the pdf $f(x)$ and then think in terms of the area of triangle(s) being swept as you move along the $x-$axis.

share|improve this answer

Let's put it this way

$$\int_{-\infty}^Y f(x)= \begin{cases} 0 & -\infty < Y < -3 \\ Y^2+3Y+{9\over 2} & -3\le Y <-2 \\ {1\over 2} & -2\le Y <2 \\ {1\over 2} +\int_2^Y(3-x)\, dx & 2\le Y < 3 \\ 1 & Y\ge 3 \end{cases}$$

The first term is INDEED including the 9/2, this is because it is

$$\int_{-3}^Y f(x)\,dx\int_{-3}^Y (x+3)\,dx$$

By the fundamental theorem of calculus, this is the antiderivative at the top limit, Y, minus the antiderivative at the bottom limit, -3. The value of $x^2/2+3x$ at $x=-3$ is $-9/2$ so you get the result with the +9/2 because you subtract the bottom limit and subtracting a negative gives a positive.

share|improve this answer

Note first of all that the cdf is defined for all $x$, so a complete answer should take care of all $x$.

If $x\lt -3$, everything is easy. We have $\int_{-\infty}^x f_X(t)\,dt=0$. So $F_X(x)=0$ if $x\lt -3$.

Now for $-3\le x\lt -2$, in effect we are integrating $t+3$ from $-3$ to $x$, since there is no "mass" before $-3$. An antiderivative is $t^2/2+3t$. Plug in. We get $\frac{x^2}{2}+3x+\frac{9}{2}$.

Note that this is $\frac{1}{2}$ at $x=-2$. The density function is then $0$ for a while, so exactly as you had it, if $-2\le x\lt 2$ then $F_X(x)=\frac{1}{2}$.

Now for $2\le x\lt 3$, we want the integral up to $2$, plus the integral from $2$ to $x$ of $3-t$. We get $$\frac{1}{2}+(3x-\frac{x^2}{2})- 4.$$ Finally, for $x\ge 3$, the cdf is $1$.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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