IDL> help,p P UINT = Array[4656, 3520] IDL> print,avg(p),avg(p>20000),avg(p>20000<22500) 22400.446 22402.729 22186.562 IDL> print,median(p),median(p>20000),median(p>20000<22500) 22480.0 22480.0 22480.0
hy wrote: Jasem and Peter,
I looked into this briefly, and saw that the median computation is not an exact one. That is, the code in fitshistogram.cpp divides the data value's range into at most 400 bins, counts how many sample values fall into each bin, finds which bin contains the median, and then uses the lowest range from the bin as the median. (An exact computation would need to resample the data, and count each possible sample value that falls into the 'median bin'). Note, btw, that the median should be an integer, and in Peter's example it is 180.1.
If the sample data ranges from 0-64K, and there are 400 bins, then the bin size is 163, so the median value could be off by that much. If its 0->4K, then the error could be 10.
See around line 270 in fitshistogram.cpp:
median[n] = i * binWidth[n] + FITSMin[n];
This is likely the issue Peter is bringing up.
Since I plan on working some on that file, I'd be happy to look into this, if you like Jasem, but it may be several weeks until I get to it.