CStats:Moment
The Moment method computes the n-th order moment about the mean of 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.
nValue = CStats:Moment( table, nOrder ) nValue = CStats:Moment( CImage, nOrder ) nValue = CStats:Moment( CImage, nOrder, CRect ) nValue = CStats:Moment( CArray, nOrder ) nValue = CStats:Moment( CArray, nOrder, CRect ) nValue = CStats:Moment( CMatrix, nOrder ) 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.
nOrder is the order of the moment to be computed and is 0 or greater.
nValue is the n-th order moment of the data. On failure, 0 is returned.
Suppose that CImage object I and CRect object R exist. The following script returns the value for 2nd Moment inside a rectangle on the image:
|
-- create a CStats object |
|
-- returns the 2nd order moment |
|
-- list the results |
The following script computes the 2nd moment for a table of numbers:
|
-- create a CStats object |
|
-- create a table to measure |
|
-- list the result |