On Fri, Dec 27, 2019 at 02:03:57AM -0000, Marco Sulla via Python-ideas wrote:
> Steven D'Aprano wrote:
> > Marco, you don't have to use median_low and median_high if you don't 
> > like them, but they aren't any worse than any other choice for 
> > calculating order statistics. All order statistics (apart from min and 
> > max) require you to sometimes make a choice between returning a data 
> > value or interpolating between two data values, and in general there are 
> > lots of choices.
> 
> Of course, but usually they are unbiased solutions by default.

That's really not true. Please read the links I provided, and keep in 
mind that in general, most of these methods will give slightly different 
answers.


> On the 
> contrary, if you don't have numeric iterables, you have to choice 
> between median_low and median_high, that introduce bias.

If your data is ordinal but not numeric, and you want the median value, 
and there are an even number of values, *you have no choice* but to pick 
one of the two middle values. To be clear, let's say we want to know the 
average (median) mark for a test out of F (fail), D, C, B, A:

    # ten students in the class
    [F, F, D, C, C, B, B, B, A, A]

There is no such mark as "halfway between C and B", and no good way 
to decide whether the median should be taken as C or B.

The best you can do is choose *ahead of time* (so that your choice is 
not biased by the result) the low median or the high median, and then be 
consistent with any other calculations you are doing.

Even if the data is numeric, you may not want to average the two middle 
values, if it could give an impossible result ("2.35 children"). For 
example:

https://stackoverflow.com/questions/48268263/finding-median-without-averaging-middle-values

The method choosen is entirely up to the person doing the calculation, 
depending on their needs and what it is that they are measuring. It's 
not for me to tell the user which median is right for them, or for you 
to say that the low and high versions are always wrong.



-- 
Steven
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/OQGDTEF77RVJP6GMLU25WC7CYC6BS3SH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to