Manuscript (Case [Issue]22595) Collection - Median is not calculated correctly for even sizes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Manuscript (Case [Issue]22595) Collection - Median is not calculated correctly for even sizes

Pharo Issue Tracker
Manuscript Notification
avatar
Jan Blizničenko opened Case 22595: Median is not calculated correctly for even sizes and assigned it to Everyone:
Bug in Project:  Collection: 1. Pharo Image  •  You are subscribed to this case
SortedCollection median does not work correctly for even amount of elements.
Median, by definition (see links below for possible definitions and explanations of median), returns middle element of sorted numbers in case of odd-sized collections.
In even-sized collections, there is no precisely middle element (in 4-sized collection the 2nd and 3rd are kinda both in the middle), therefore median is defined as average of these two "middle" elements (in case of 4-sized collection, it is average of 2nd and 3rd element).
However, current implementation of SortedCollection>>#median just returns element before the "middle", so (in case of 4-sized collection), it returns 2nd element, although it should return average of 2nd and 3rd.

I understand that median can be sent even to collections of strings, classes or whatever that cannot be averaged, but this way it does not comply to definition of median and therefore should not be called that.

https://www.dictionary.com/browse/median
https://searchdatacenter.techtarget.com/definition/statistical-mean-median-mode-and-range
https://en.wikipedia.org/wiki/Median

Jan
Priority Priority: 5 – Fix If Time Status Status: Work Needed
Assigned To Assigned to: Everyone Milestone Milestone: Later

Go to Case
No longer need updates? Unsubscribe from this case.

Don't want Manuscript notifications anymore? Update your preferences.

Manuscript

_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
https://lists.gforge.inria.fr/mailman/listinfo/pharo-bugtracker