KPG1_FRACx

Finds values corresponding to specified fractions of an array’ s ordered distribution

Description:

This routine finds the values at defined fractions of an array s ordered distribution, such as percentiles. Thus to find the upper-quartile value, the fraction would be 0.75. Since it uses an histogram technique rather than sorting the whole array, for efficiency, the result may not be exactly correct. However, the histogram has a large number of bins (10000), combined with linear interpolation between bins in the routine reduce the error. The histogram extends between the minimum and maximum data values.

The routine also has an iterative method, whereby outliers, which compress the vast majority of data values into a few bins, are excluded from the histogram. Clipping occurs from both ends. A contiguous series of bins are removed until the largest or smallest fraction is encountered. Where the rejection of bins end, defines new limits, encompassing the vast majority of values. A new histogram is calculated using these revised limits. The excluded outliers are still counted in the evaluation of the fractions. The criterion for iteration may need tuning in the light of experience. At present it is when there are fewer than 4% non-zero bins.

The iteration can still fail to find accurate fractional values if smallest and largest fractions are close to 0 or 1 and correspond to extreme outliers. The routine recognises this state and determines the values for each outlier fraction separately, and then uses the next interior fraction as the limit. Then the routine proceeds with the clipping described above.

Invocation

CALL KPG1_FRACx( EL, ARRAY, NFRAC, FRAC, BAD, CLFRAC, VALUES, STATUS )

Arguments

EL = INTEGER (Given)
The number of elements of the array to be analysed.
ARRAY( EL ) = ? (Given)
The array for which the chosen statistics are required.
NFRAC = INTEGER (Given)
Number of fractional positions.
FRAC( NFRAC ) = REAL (Given and Returned)
Fractional positions in the histogram in the range 0.0–1.0. On exit they are arranged into ascending order.
BAD = LOGICAL (Given and Returned)
True when bad pixels may be present.
CLFRAC( NFRAC ) = REAL (Returned)
The clipped fractional positions in the histogram in the range 0.0–1.0 after iterative clipping of the histogram.
VALUES( NFRAC ) = DOUBLE PRECISION (Returned)
Values corresponding to the ordered fractional positions in the histogram.
STATUS = INTEGER (Given & Returned)
Global status.

Notes:

Deficiencies