|
mean (replaces TMean)
The mean function returns the mean of a
1-dimensional array,
CImage, or list of numbers. The parameters must
contain numbers or strings that can be converted to numbers. This
function is similar to the
CStat:Mean method but does not require calling
new_stats() beforehand to create a
CStats object. The
meansdev function calculates both the mean and
standard deviation of a 1-dimensional array,
CImage, or list of numbers.
Whereas this function operates on a pure (indexed)
array, the slightly slower
meann and
meansdevn functions caculate the mean value for a
general table that may be a multi-dimensional array or contain a
mixture of numbers, strings, named keys, and sub-tables.
Syntax
nMean = mean( Data )
Data is a
1-dimensional array, list of numbers or a
CImage object.
n1,
n2, n3, ... are numbers or string values
that can be converted to numbers.
nMean is the mean of
the data.
Remarks
The
CImage class supports values ranging from
byte to double plus other pixel types.
Examples
The following script returns the mean and standard
deviation of a table containing 1 million random numbers.
|
t = random( 1000000 )
|
|
|
v = mean( t )
|
|
|
Printf("Mean=%lg\n", v )
|
|
The next script returns the mean value for pixels
inside a rectangle at the corner of a
CImage.
|
V = AttachView( "CImageView"
)
|
|
|
Assert( V and V:Count() > 0
)
|
|
|
R = new_rect( 1, 20, 1, 40
)
|
|
|
v = mean( V:GetImage(), R
)
|
|
|
Printf("Mean=%lg\n", v )
|
|
The next example computes the mean value of a list
of numbers:
|
m, s = meansdev( 5, 6, -2, 5.4
}
|
|
|
Printf("M= %lg, S= %lg\n",
m, s )
|
|
Related Topics
Table and Array Functions
meansdev
meann
meansdevn
median
sdev
CImageView Class
CStats class
Mira Pro x64 Script User's Guide, v.8.76 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.
|