Finds the mean, median and mode iteratively using the Chauvenet rejection criterion
KPG_IMMMx
It makes a first estimate of the statistics, and then refines these by including or excluding values at either end of the sorted values, deciding which values to reject using the Chauvanet criterion. Iterations stop once no more values are rejected; or the statistics stabilise; or there is an oscillation between two states, in which case the returned statistics are the averages found in these two states; or there are too few values remaining.
There is a routine for each of the standard numeric types. Replace "
x"
in the routine name by D, R, I,
W, UW, B or UB as appropriate. The data type of the array being analysed must match the particular
routine used.
The supplied array need not be sorted.
The minimum sample size throughout is five.
The magic-value method is used for bad pixels.
The initial statistics start from the median and a symmetric interval about that. Deviations from that median derive the initial mean and variance, and a new median.
In the iterations the new symmetric value range is about the mode, the half width being the Chauvenet number of standard deviations plus half the average separation of mean and mode. The median averages the central nine values to derive a more robust estimate.