CStats:SigmaClipMean


The SigmaClipMean method computes the mean value of a data sample using iterative sigma rejection to exclude deviant values from the statistic. The sample may be a Lua table or a class object of type CImage, CArray, or CMatrix. For CImage and CMatrix objects, an optional CRect object can be used to define the points used in the calculation.

Syntax

nMean, nStdDev = CStats:SigmaClipMean( table, nHigh, nLow )

nMean, nStdDev = CStats:SigmaClipMean( CImage, nHigh, nLow )

nMean, nStdDev = CStats:SigmaClipMean( CImage, nHigh, nLow, CRect )

nMean, nStdDev = CStats:SigmaClipMean( CArray, nHigh, nLow )

nMean, nStdDev = CStats:SigmaClipMean( CArray, nHigh, nLow, CRect )

nMean, nStdDev = CStats:SigmaClipMean( CMatrix, nHigh, nLow )

where

    table is a lua table containing the data.

    CImage, CArray, and CMatrix are class objects containing the data to measure,

    CRect is a CRect rectangle object that defines the region to measure.

    nHigh and nLow specify the sigma values to reject from the upper and lower ends of the sample distribution.

    nMean and nStdDev are the clipped mean value and standard deviation, respectively. On failure, 0,0 is returned.

  

The calculated statistic trims bad data away from the mean value using the standard deviation to identify and exclude deviant values in an iterative fashion. Use this method to reduce the biased result when the region contains a moderate percentage of deviant pixel values.

This method uses the same algorithm as the SigmaClip method of the CImCombine class.

Examples

Suppose a CImage I and a CRectR exist. The following script returns the clipped mean value inside a rectangle on the image. The clipping is done at 3 sigmas above the mean and 5 sigmas below the mean:

S = CStats:new()

-- create a CStats object

n = S:SigmaClipMean( I, 3, 5, R )

-- clips 3 sigmas above and 5 sigmas below

Printf("mean=%lg\n", n )

-- list the results

The following script returns the Sigma-clipped mean value for a table of data. Clipping is done at 3 sigmas above the mean and 5 sigmas below the mean:

S = CStats:new()

-- create a CStats object

t = { 4,1,4,2,2.1,5,6.4,2,-1.4,-.5,3,4 }

-- create some data in a table

Printf("mean=%lg\n", S:SigmaClipMean(t,3,5) )

-- list the result

Related Topics

MinMaxClipMean

MtmSigmaClipMean

RankClipMean

CStats Class