KPG_STOCx

Calculates accurate order statistics by sorting an array

Description:

This routine calculates the median and optionally up to one-hundred percentiles. It achieves this by using Quicksort to order the good array values, and hence provide correct values (unlike the faster histogram approximation used by KPG1_HSTAx).

A clipped range may be supplied, such as found by KPG_OSTAx, to derive ordered statistics after clipping of outliers.

Invocation

CALL KPG_STOCx( EL, ARRAY, NGOOD, NUMPER, PERCNT, RANGE, MEDIAN, PERVAL, STATUS )

Arguments

EL = INTEGER (Given)
Total number of pixels in the array.
ARRAY( EL ) = ? (Given)
The vectorised array of values whose ordered statistics are to be calculated.
NGOOD = INTEGER (Given)
Number of valid pixels which contributed to the statistics.
NUMPER = INTEGER (Given)
Number of percentiles values to report. This should be in the range 1 to 100. Set this to 1 and PERCNT(1) to VAL__BADR if percentiles are not required.
PERCNT( NUMPER ) = REAL (Given)
The percentiles to derive. Valid percentiles must be in the range 0.0 to 100.0, and preferably in ascending order. If the first element is set to the bad value, then no percentiles are calculated.
RANGE( 2 ) = DOUBLE_PRECISION (Read)
The clipping limits between which to statistics are to be determined, lower then upper. A bad value means no limit is needed at its respective end.
MEDIAN( 2 ) = DOUBLE PRECISION (Returned)
Median value. If there is an even number of good values present in the array, the median is the average of the middle pair. The second value is the clipped median after application of the RANGE bounds. If both RANGE values are bad no clipping is performed and the clipped median is set to the bad value.
PERVAL( NUMPER, 2 ) = DOUBLE PRECISION (Returned)
Percentile values corresponding to the percentile fractions in PERCNT. The second set of percentiles are the clipped values after application of the RANGE bounds. If both RANGE values are bad no clipping is performed and the clipped percentiles are set to the bad value.
STATUS = INTEGER (Given and Returned)
The global status.

Notes: