# Choosing an interval of the CDF to find each quartile

I have a random variable $$X$$ which has the following CDF: $$F(y) = \left\{\begin{array}{ll} 0 & : y \lt 0\\ \frac{y}{30} & : 0 \le y \lt 20\\ \frac{2}{3} + \frac{y-20}{60} & : 20 \le y \lt 40\\ 1 & : y \ge 40 \end{array} \right.$$

To find the median of $$X$$, I know I need to plug $$q_2$$ into the CDF and set it equal to 0.5: $$F(q_2) = 0.5$$ and solve for $$q_2$$. But which interval of the CDF should I use? My intuition tells me it would be the third interval since 20 falls in the middle of 0 and 40 and this is the interval that would be used for $$F(20)$$, but I have a feeling this is wrong. Which one should I use for $$q_2$$, as well as $$q_1$$ and $$q_3$$?

• A CDF is increasing, so you can check that for instance the CDF is at least 2/3 on the third interval just by plugging in $y=20$. – Ian Sep 27 '18 at 17:41

I found the answer so I'll go ahead and post it here:

The easy way is just to make a guess and plug in the quartile using any of the intervals. If the result falls within the interval you chose, it is correct. If not, pick a different one.

If your random variable $$X$$ has the cdf

$$F(y) = \left\{\begin{array}{ll} 0 & : y \lt 0\\ \frac{y}{30} & : 0 \le y \lt 20\\ \frac{2}{3} + \frac{y-20}{60} & : 20 \le y \lt 40\\ 1 & : y \ge 40 \end{array} \right.$$

you're supposed to find the inverse so you get $$F(y) = \frac{y}{30}$$ for $$y$$. then the inverse is $$30y$$. If plug in $$F^{-1}(.5) = \frac{1}{2}30 = 15$$

I'll just note you switch from $$X$$ to $$y$$. You can also see it has $$\frac{2}{3} + \frac{y-20}{60}$$. If you plug in $$y=20$$ you get $$\frac{2}{3}$$