Hi all, I had a quick question about the MEDIAN function in IDL that I can't seem to find answers to (https://www.l3harrisgeospatial.com/docs/median.html). I've noticed that when using MEDIAN, you must specify /EVEN as a keyword, otherwise in the case you have an even dataset, the MEDIAN function won't take the average of the middle two numbers. E.g. x = [1,2,3,4] MEDIAN(x) = 3 MEDIAN(x,/EVEN) = 2.5 As far as I'm aware, if you take the MEDIAN on an even set of numbers, you're supposed to average (mean) the middle two. Yet for some reason, the 'default' in IDL is that (unless you specify even), it always gives you what I'm calling the 'upper median'. So MEDIAN([5,6,7,8]) = 7, MEDIAN([10,11,12,13]) = 12, i.e. the value just past halfway through the array. My question is simple: does anybody know why IDL does this by default? Is it 'wrong' to not average the middle two numbers if you're taking the median of a dataset? I processed all the data I was working with using MEDIAN without the /EVEN keyword and I'm trying to figure out whether it's worth reprocessing or not... Thanks James
|