sortr sub

stats (replaces TStats)


The stats function computes the mean, standard deviation, and other basic statistics for numeric data and returns them in an indexed table. The parameters may be a CImage, CMatrix, or CArray object, a 1-dimensional array, or a list of numbers. The array and list parameters must contain a mixture of numbers and strings that can be converted to numbers.

Syntax

tbl = stats( CImage )

tbl = stats( CImage, CRect )

tbl = stats( array )

tbl = stats( n1, n2, n3, ... )

where

bullet.gif    CImage is an image object;

bullet.gif    CRect is a rectangle object;

bullet.gif    array is a 1-dimensional table;

bullet.gif    n1, n2, n3, ... are numbers or string values that can be converted to numbers.

On success, tbl is returned as an array containing the following 8 values:

bullet.gif      tbl[1] is the mean value returned in table index 1.

bullet.gif      tbl[2] is the median value returned in table index 2.

bullet.gif      tbl[3] is the standard deviation returned in table index 3.

bullet.gif      tbl[4] is the minimum value returned in table index 4.

bullet.gif      tbl[5] is the maximum value returned in table index 5.

bullet.gif      tbl[6] is the statistical skewness returned in table index 6.

bullet.gif      tbl[7] is the statistical kurtosis returned in table index 7.

bullet.gif      tbl[8] is the number of values in the sample returned in table index 8.

bullet.gif    On failure, nil is returned.

Example

Suppose a CImage I exists. The following script returns the mean and standard deviation of 600 pixels in the corner of the image:

tbl = stats( I, new_rect( 10,30,15,35 )

-- computes values inside the CRect

Printf("mean=%lg +/- %lg\n", tbl[1], tbl[3] )

-- list the result

S:delete()

-- when done with S, delete it

Related Topics

Table and Array Functions

CStats class

CStats:Stats

CImage class

CRect class

mean

sdev

 


Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.