The random variable $X$ has the probability density function given by: $$ f(x) = \begin{cases} \frac{2x}{3}, & 0 \le x \le 1 \\ \frac{2}{3}, & 1 \lt x \le 2 \\ 0, & \text{otherwise} \end{cases} $$ Find the median of $X$.
I know that the CDF is needed to calculate the median, which I calculated as follows:
$$ F(X) = \begin{cases} 0, & x \lt 0 \\ \frac{x^2}{3}, & 0 \le x \le 1 \\ \frac{2x}{3}, & 1 \lt x \le 2 \\ 1, & x \gt 2 \end{cases} $$
Since $\int{\frac{2x}{3}} = \frac{x_0^2}{3}$ and $\int{\frac{2}{3}} = \frac{2x_0}{3}$. I then thought that I could find the median as follows:
$$ \frac{m^2}{3} + \frac{2m}{3} = 0.5 \\ 2m^2 + 4m - 3 = 0 \\ m = \frac{-2+\sqrt10}{2} $$
Ignoring the - value because it falls outside the range of interest. The correct answer is $1.25$ and I'm a bit confused on how to find it. Could somebody explain where I went wrong?
Basically you are looking for the value $m$ which fulfill the equation $F_X(m)=0.5$. If you have a pdf with intervals you start to prove if the first interval is larger or equal to 0.5.
$\int_0^1 \frac{2x}{3} \, dx =\frac13<0.5$
We need the second interval of the cdf. The cdf of the second interval is
$$\int_0^1 \frac{2x}{3} \, dx+\int_1^m \frac{2}{3} \, dx=0.5$$
So you have really to calculate both integrals including the bounds:
$$\left[\frac{x^2}{3} \right]_0^1+\left[\frac{2x}{3} \right]_1^m=0.5$$
$$\frac{1}{3} +\frac{2m}{3}-\frac{2}{3}=0.5$$
All it is left is to solve the equation for $m$. The left hand side is the cdf of the second interval: $\frac{2x}{3}-\frac{1}{3}$. If we insert the upper bound we obtain $\frac{2\cdot 2}{3}-\frac{1}{3}=\frac{4-1}3=1$. This is the result we expect.