How to calculate median via interpolation I am reading a text on data mining. I came across this formula, but I do not understand how to apply it. There aren't any examples following the forumla and my research online has produced very few results. Can someone explain how to apply this formula?

 A: Let's suppose we have three groups
0-20000       20 
20000-39999   60
40000-        20 

where the second column is frequency, and also percent. The median must be within the second group as $20\%$ are less and $20\%$ are more.
Then the recipe gives
$20000 + [(50 - 20) / 60] \times 20000$
which is $20000 + 0.5 \times 20000 = 30000.$
which is halfway through the median interval, as it should be: I deliberately made the example really simple (and symmetric). If we had instead
0-20000       25
20000-39999   60
40000-        15

so that the recipe yields
$20000 + [(50 - 25) / 60] \times 20000 \approx 31667$
it should be clear that the median should be nearer the lower end of its interval than the top, because the cumulative probability at the bottom ($25\%$) is nearer $50\%$ than is the cumulative probability at the top ($85\%$).
It may help to draw cumulative bar charts with simple numerical examples and consider interpolation geometrically.
Let's spell it out: the assumption here is that within each bin, the distribution is uniform. If there are lots of bins, that assumption may work well. Otherwise it is not necessarily the only alternative. For example if all upper bin limits are positive, and the distribution is right or positively skewed, then interpolation on the logarithms of upper bin limits may work better.
A: You have binned data, $k$-th bin contains $freq_k$ points, and has some width $width_k = U_k - L_k$ where $L_k$ is the lower bound for the interval, and $U_k$ is the upper bound (e.g. "\$10-20,000").

*

*Median is located at the $N/2$ point (median is a middle value of a sorted list of values).

*$\sum(freq)$ is the number of points in the bins before the middle bin. In such a case, median would be located at $\sum(freq) + \delta = N/2$ position of a sorted list of points, so $\delta = N/2 - \sum(freq)$ is how many points we are missing till hitting the median.

*$\phi = \delta \big/ freq_{median}$ translates the number of points $\delta$ into the fraction $\phi$ of the median interval. It's the number of points before median divided by the number of points in the interval.

*$L_1 + \phi \,\times\, width$ says that median is located in the $\phi \,\times width$ location of the interval, and you need to move that many units from the lower bound $L_1$ to get there. Here we're moving from counts, to the actual units (e.g. dollars, as in the example).

Try drawing this.

