CStats:YpMean


The YpMean method computes the mean value of a data sample using "Yp Mean" estimation to reduce the influence of deviant pixels. 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:YpMean( table, nExp )

nMean, nStdDev = CStats:YpMean( CImage, nExp )

nMean, nStdDev = CStats:YpMean( CImage, nExp, CRect )

nMean, nStdDev = CStats:YpMean( CArray, nExp )

nMean, nStdDev = CStats:YpMean( CArray, nExp, CRect )

nMean, nStdDev = CStats:YpMean( CMatrix, nExp )

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.

    nExp is the exponent used in the Yp Mean calculation.

    nMean and nStdDev are the yp-power mean and standard deviation, respectively. On failure, 0,0 is returned.

  

This method assigns weights to values based upon their distance from the mean value. No rejection ("clipping") is performed. In contrast to the geometric mean, this method can be tuned to assign less weight to positive values or less weight to negative values, and the severity of the weighting scheme may be adjusted. The positive or negative tail bias depends upon the value of the exponent parameter and the severity of the weighting depends upon the absolute value of the exponent parameter.

For an exponent parameter of value y, the statistic is computed by summing each sample member x raised to the power y as shown below. (Note: The symbol ^ denotes raising a number to a power, as in 2^3 = 8):

     Total = Sum(x^y)

The resulting mean value is then re-scaled as

     Statistic = Total^(1/y) . Thus

    p=0 is invalid. Do not use.

    p>0 gives higher weight to positive outliers.

    p<0 gives lower weight to negative outliers.

Examples

Suppose a CImage I and a CRect R exist. The following script returns the Yp Mean value inside a rectangle on the image:

nVal = S:YpMean( I, 0.25, R )

-- return the Yp Mean value for exponent 0.25

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

-- list the result

The following script returns the Yp mean value for a table of data using Y-power value 0.4:

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:YpMean(t,0.4) )

-- list the result

Related Topics

GeomMean

ContraMean

CStats Class