Posted By: johnnyp
Median calculation gives dodgy result - 09/18/17 21:43
Code:
var a[4] = {1, 4, 3, 5}; printf("n%f", Median(a, 4)); printf("n%f", Percentile(a, 4, 50)); # output 4.500000 4.500000
Unless I am much mistaken the median value should be 3.5
Median() always gives the right answer when length is even, and never when length is odd.