KPG1_MODEx

Estimates the mean of a number of normally distributed data values, some of which may be corrupt

Description:

The routine is based on maximising the likelihood function for a statistical model in which any of the data points has a constant probability of being corrupt. A weighted mean is chosen according to the deviation of each data point from the current estimate of the mean. The weights are derived from the relative probabilities of being valid or corrupt. A sequence of these iterations converges to a stationary point in the likelihood function. The routine approximates to a k-sigma clipping algorithm for a large number of data points and to a mode-estimating algorithm for fewer data points.

Invocation

CALL KPG1_MODEx( X, NX, PBAD, NITER, TOLL, XMODE, SIGMA, : STATUS )

Arguments

X( NX ) = ? (Given)
An array of data values.
NX = INTEGER (Given)
The number of data values.
PBAD = REAL (Given)
An estimate of the probability that any one data point will be corrupt. (This value is not critical.)
NITER = INTEGER (Given)
The maximum number of iterations required.
TOLL = REAL (Given)
The absolute accuracy required in the estimate of the mean. Iterations cease when two successive estimates differ by less than this amount.
XMODE = REAL (Returned)
The estimate of the uncorrupted mean.
SIGMA = REAL (Returned)
An estimate of the uncorrupted standard deviation of the data points.
STATUS = INTEGER (Returned)
The global status.

Notes:

There is a routine for each numeric data type: replace " x" in the routine name by D, R, I, W, UW, B, UB as appropriate. The array supplied to the routine must have the data type specified.