KPG_STOSx

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).

Invocation

CALL KPG_STOSx( EL, ARRAY, NGOOD, NUMPER, PERCNT, 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.
MEDIAN = 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.
PERVAL( NUMPER ) = DOUBLE PRECISION (Returned)
Percentile values corresponding to the percentile fractions in PERCNT.
STATUS = INTEGER (Given and Returned)
The global status.

Notes: