CStats:SdevValue


The SdevValue method computes the Standard Deviation of a data sample using a mean value which is supplied, rather than calculated. 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

nStdDev = CStats:SdevValue( table, nValue )

nStdDev = CStats:SdevValue( CImage, nValue )

nStdDev = CStats:SdevValue( CImage, nValue, CRect )

nStdDev = CStats:SdevValue( CArray, nValue )

nStdDev = CStats:SdevValue( CArray, nValue, CRect )

nStdDev = CStats:SdevValue( CMatrix, nValue )

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.

    nValue is the value about which to calculate the standard deviation.

    nStdDev is the standard deviation of the data. On failure, 0 is returned.

Example

The following script returns the standard deviation relative to a specified mean value::

S = CStats:new()

-- create a CStats object

nMean = 1020.24

-- set the target mean value

nSdev = S:SdevValue( I, nMean, R )

-- return the standard deviation relative to nMean

Printf("Sdev=%lg\n", nSdev)

-- list the results

The following script returns the standard deviation for a table of data relative to a mean value of 1.54:

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:SdevValue(t,1.54) )

-- list the result

Related Topics

Sdev

SdevClip

SdevClipValue

CStats Class