CStats:Sdev


The Sdev method computes the Standard Deviation for the distribution of values in a data 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

nStdDev = CStats:Sdev( table )

nStdDev = CStats:Sdev( CImage )

nStdDev = CStats:Sdev( CImage, CRect )

nStdDev = CStats:Sdev( CArray )

nStdDev = CStats:Sdev( CArray, CRect )

nStdDev = CStats:Sdev( CMatrix )

where

    nMeanValue is a target mean value about which the standard deviation is calculated.

    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.

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

Examples

Suppose a CImage I and a CRect R exist. The following script returns the standard deviation relative to the simple arithmetic mean value inside a rectangle on the image:

S = CStats:new()

-- create a CStats object

nSdev = S:Sdev( I, R )

-- return the standard deviation

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

-- list the results

The following script returns the standard deviation for a table of data:

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("Sdev=%lg\n", S:Sdev(t) )

-- list the result

Related Topics

SdevValue

SdevClip

SdevClipValue

CStats Class