Opened 11 years ago

Closed 11 years ago

#497 closed defect (fixed)

Center (se.lu.onk.Center) median calculation is flawed and should be replaced

Reported by: olle Owned by: olle
Priority: major Milestone: ZZ Other tickets
Component: se.lu.onk series plug-ins Keywords:
Cc:

Description

Center (se.lu.onk.Center) median calculation is flawed and should be replaced. The idea behind the current algorithm is not clear, and it will only give the correct result in very special cases. The algorithm should be replaced by a more general one.

Change History (1)

comment:1 by olle, 11 years ago

Resolution: fixed
Status: newclosed

(In [2012]) Fixes #497. Refs #79. Class/file center/Center.java in se.lu.onk.Center updated in median calculation:

  1. Private method median(List<Float> vec) is updated by replacing the current algorithm by a call to new private method float calculatePercentile(List<Float> vec, float fraction), with fraction value set to 0.5.
  2. New private method float calculatePercentile(List<Float> vec, float fraction) added. It first sorts the values in ascending order (the original input list is not changed), and then returns a weighted value of the list values of the two index values nearest to the desired percentile. If the percentile corresponds exactly to an integer index, the list value for that index is returned.

Note: See TracTickets for help on using tickets.