CStats:AlphaClipMean


The AlphaClipMean method computes the mean and standard deviation for a data sample. excluding the nHigh highest and nLow lowest 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:AlphaClipMean( table, nHigh, nLow )

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

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

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

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

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

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

  

The calculated statistic excludes a specified numbers of lowest and highest values from the sample. The parameters n and m are known as "alpha" values. In comparison, the MinMaxClippedMean method uses alpha values of 1,1. For example, if nLow=10 andnHigh=20 , then the 10 lowest and 20 highest values in the sample are excluded from the calculation.

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

Examples

Suppose that CImage object I and CRect object R exist. The following script returns the alpha-clipped mean value inside a rectangle on the image:

S = CStats:new()

-- create a CStats object

nMean = S:AlphaClipMean( nHigh, nLow )

-- return the mean value

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

-- list the result

The following script returns the alpha-clipped mean value for a table of data, clipping off the 2 highest and 1 lowest values in the table:

S = CStats:new()

-- create a CStats object

t = { 4, 4, 2, 5, 6.4, -1.42, -12, 3.4 }

-- create some data in a table

Printf("mean=%lg\n", S:AlphaClipMean(t,2,1) )

-- list the result

Related Topics

MinMaxClipMean

SigmaClipMean

RankClipMean

MtmSigmaClipMean

CStats Class