CStats:MtmSigmaClipMean


The MtmSigmaClipMean method computes the modified trimmed mean value and standard deviation for a data sample. excluding the nHigh and nLow sigma of values from the sample. 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:MtmSigmaClipMean( table, nHigh, nLow )

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

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

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

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

nMean, nStdDev = CStats:MtmSigmaClipMean( 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 for values to reject from the upper and lower ends of the sample distribution.

    nMean and nStdDev are the MTM-clipped mean and standard deviation of the data. On failure, 0,0 is returned.

  

The Modified Trimmed Mean ("MTM") excludes outliers from a sample by comparing their deviation from the Median, rather than the Mean. The returned value is the mean of the final sample of non-excluded points. This algorithm trims bad data away from the mean value using the standard deviation and median value in an iterative fashion. Use this method to reduce the biased result when the region contains a large percentage of deviant pixel values.

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

Examples

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

S = CStats:new()

-- create a CStats object

nMean = S:MtmSigmaClipMean( I, 3, 5, R )

-- clips 3 sigmas above and 5 sigmas below

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

-- list the results

The following script returns the MTM-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:MtmSigmaClipMean(t,3,5) )

-- list the result

Related Topics

MinMaxClipMean

SigmaClipMean

RankClipMean

AlphaClipMean

CStats Class