[Math] how to find the median percentile from a pdf like this

percentileprobability

$f(x)=1/3$ if $0<x<1$ and $2<x<4$ and $0$ elsewhere

i found the cdf which is
$F(x) = \frac13 x$ for $0<x<1,$ $\frac13$ for $1<x<2,$ $\frac x3-\frac13$ for $2<x<4,$ $1$ for $x>4$

how do i find the 25th and 50th percentile from a cdf like this?

pls help ! thanks

Best Answer

The CDF is $$F(x) = \begin{cases}0, &\textrm{if } x < 0 \\ \frac13 x, & \textrm{if } 0\leq x<1 \\ \frac13, & \textrm{if } 1\leq x <2 \\ \frac13 x - \frac13, & \textrm{if } 2\leq x< 4 \\ 1, & \textrm{if } x \geq 4 \end{cases}$$

So you can see that your median $x_{0.50} = F^{-1}(\frac12)$ is found by solving $$\tfrac13 x_{0.50} - \tfrac13 = \tfrac12$$ $$\tfrac13 x_{0.50} = \tfrac56$$ $$x_{0.50}=\boxed{\tfrac52}$$

and the $25^{\textrm{th}}$ percentile $x_{0.25}=F^{-1}(\frac14)$ is found by solving $$\tfrac13 x_{0.25} = \tfrac14$$ $$x_{0.25}=\boxed{\tfrac34}$$

How did we know which piece of the definition of $F$ to use in each case? By observing that the first piece produces values of $F$ no more than $\frac13$ (that's where $0.25$ lies) and the third piece produces values of $F$ at least $\frac13$ (that's where $0.5$ lies).

In fact, this shows how to compute nearly all percentiles. For $0<p<1$ (except for $p=\tfrac13$), you have

$$x_p = F^{-1}(p) = \begin{cases}3p, & \textrm{if } 0\leq p<\tfrac13 \\ 3p+1, & \textrm{if } \tfrac13 <p\leq 1 \end{cases}$$

For the case $p=\tfrac13$, any number in $[1,2]$ might be considered a valid value for $x_{1/3}$, and different authors define it differently.