Calculating cdf given the probability density function

43 Views Asked by At

I'm trying to work out the cdf given this probability density function:
$$ f(x)=\begin{cases} \frac{1}{4} & {0<x<2}\\ \frac{1}{2}x+c & {2<x<3}\\ 0, & \text{elsewhere} \end{cases} $$

While this being the given solution: $$ F(x)=\int^x_{-\infty}f(t)dt=\begin{cases} \int^x_0 \frac{1}{4}dt=\frac{x}{4}\\ \int^x_2(\frac{1}{2}t-\frac{3}{4})dt+k=\frac{x^2-3x}{4}+\frac{1}{2}+k\\ \end{cases} $$ Under the two levels, F(2) must be the same (reason for introducing k).
$\rightarrow F(2)=\frac{1}{2}=k$ $$ \therefore F(x)=\begin{cases} 0, & {x<0}\\ \frac{x}{4} & {0 \leqslant x \leqslant 2}\\ \frac{x^2-3x}{4}+1 & {2 \leqslant x \leqslant 3}\\ 1, & {x>2} \end{cases} $$

I know how to work out cdfs but could someone explain to me by demonstration how $\frac{1}{2}x+c$ in the pdf changes to $\frac{x^2-3x}{4}+1$ in the cdf and also why the inequality signs denoting the ranges of x also change respectively.

1

There are 1 best solutions below

0
On BEST ANSWER

Recall that a probability density function must integrate to $1$. So we have \begin{align} 1 &= \int_{\mathbb R}f(x)\ \mathsf dx\\ &= \int_0^2 \frac14\ \mathsf dx + \int_2^3\left(\frac12 x+c\right)\ \mathsf dx\\ &= \frac12 + \frac14(3^2-2^2)+c\\ &= \frac74 + c, \end{align} so that $c = -\frac34$. To find the distribution function $F(x) = \mathbb P(X\leqslant x)$, we integrate the density; for $0\leqslant x\leqslant 2$ we have $$ F(x) = \int_0^x f(y)\ \mathsf dy = \int_0^x \frac14\ \mathsf dy = \frac x4. $$ For $2\leqslant x\leqslant 3$ we have \begin{align} F(x) &= \int_0^x f(y)\ \mathsf dy\\ &= \int_0^2 f(y)\ \mathsf dy + \int_2^x f(x)\ \mathsf dy\\ &= \frac 12 + \int_2^x \left( \frac 12 y-\frac34\right)\ \mathsf dy\\ &= \frac 12 + \frac14(x-2)(x-1)\\ &= \frac{2+(x-1)(x-2)}4\\ &= \frac{x^2-3x}4 + 1. \end{align} Note that $F(0)=0$ and $F(3)=1$, as we should expect.