# Median from probability density function

I have a probability density function:

$$f(x) = \begin{cases} \frac 1 4xe^{\frac {-x}2}, & x\ge0 \\ 0, & x < 0\end{cases}$$

To add more detail, cdf is:

$$F(x) = \begin{cases} 1+\frac{-1}2xe^{\frac {-x}2}-e^{\frac {-x}2}, & x\ge0 \\ 0, & x < 0\end{cases}$$

Find the $$Med(x)$$.

Solving

$$\int_{-\infty}^{x} f(x) dx=1+\frac{-1}2xe^{\frac {-x}2}-e^{\frac {-x}2}=\frac 12$$

I found 2 values $$3.3567$$ and $$-1.5361$$, and my book said that the answer is $$-1.5361$$. This is confusing because I thought $$Med(X)\ge 0$$.

• The median is unique. So you can’t find two values. – mathcounterexamples.net Dec 26 '18 at 13:16
• I solve the equation and it gives me 2 $x$ values, I haven't determined which $Med(X)$ is yet. – Tjh Thon Dec 26 '18 at 13:17
• Which equation did you solve? Please update the question with what you did. – mathcounterexamples.net Dec 26 '18 at 13:18
• I have edited my post. – Tjh Thon Dec 26 '18 at 13:24
• Only the non-negative solution should be median since you used that part of the cdf for which $x\ge 0$; $F(x)$ cannot be $1/2$ for any $x<0$. – StubbornAtom Dec 26 '18 at 13:46

Your PDF is for the distribution $$\mathsf{Gamma}(\text{shape}=2,\text{rate}=\frac 1 2).$$ See the relevant Wikipedia page (or your textbook) for details. You seek $$F_X^{-1}(\frac 1 2) = 3.356694.$$
In R statistical software, the inverse CDF (quantile function) is denoted qgamma with appropriate arguments.
qgamma(.5,2,1/2)