Remix.run Logo
NooneAtAll3 2 days ago

I thought this was going to be about computing (a+b)/2 avoiding overflows

foobar1962 2 days ago | parent [-]

That's average or mean. Median is the middle value.

From the article:

> It can lead to some discussion about statistics and why you might prefer a median to a mean in most cases.

My best example for median vs mean is property prices, where very expensive properties will skew the mean (average value) upwards but the median (middle value) will remain about the same.

SeanSullivan86 2 days ago | parent | next [-]

The overflow thing would be about computing the median of some sub-range of a sorted array. It is an often-quizzed thing that comes up as an edge case in binary search of a large array, but could apply to anything where you need to select the middle element of a sub-range of an array and the sum of the start/end indices could overflow.

I think the lore is that it was a bug in Java?'s binary search lib decades ago?

jrpelkonen 2 days ago | parent [-]

Indeed: https://research.google/blog/extra-extra-read-all-about-it-n...

P.S. I can’t believe this happened over 20 years ago, I must be old.

justinpombrio 2 days ago | parent | prev | next [-]

> That's average or mean. Median is the middle value.

The median of an even number of values is typically defined to be the mean of the two middle-most values.

godelski 2 days ago | parent | prev [-]

There's also an interesting relationship to variance when you only have mean and median