Let $f(x) = \log\left ( \frac{x}{x+5} \right )$
I would like to find the median for $f(x)$ over the interval [0,5]. In practice, I have been using [1e-10,5].
One way to find the median is to take the middle value of x over [0,5]. In my case, it would be 2.5. Hence, the median would be simply
$\log\left ( \frac{2.5}{7.5} \right )=-1.098612$
Another possible solution would be:
$\frac{\textrm{50 percent of the area}}{\textrm{total area}}= \frac{\int_{0}^{m}\log\left (\frac{x}{x+5}\right) dx}{\int_{0}^{5} \log\left (\frac{x}{x+5 }\right )dx}=0.5$
In other words, the median for the function is found with the value m that gives 50% of the area on the interval [0,5]. We can find it iteratively. Using R, I have got:
$\frac{\textrm{50 percent of the area}}{\textrm{total area}}=\frac{-3.465738}{-6.931473} =0.5$.
The value m that gives 50% of the area is 1.469077. Hence, the median for the function would be:
$\log\left ( \frac{1.469077}{1.469077+5} \right )=-1.482399$
Should both approaches give similar results? If not, which one would be correct?
Cheers!
Tyler