KPG1_WMODx

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. The data points have weights, to allow for different intrinisic errors. 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_WMODx( X, W, NX, PBAD, NITER, TOLL, XMODE, SIGMA, : STATUS )

Arguments

X( NX ) = ? (Given)
An array of data values.
W( NX ) = REAL (Given)
An array of data weights for each data value. The weights are inversely proportional to the square of the relative errors on each data point.
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 normalised standard deviation of the data points. An estimate of the standard deviation of any one point is: SIGMA / SQRT( W ) where W is its weight.
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.