statstr


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

This function returns ["name"]=value pairs, whereas stats returns an indexed array, like [1]=value.

Syntax

tbl = statstr( CImage )

tbl = statstr( CImage, CRect )

tbl = statstr( CMatrix )

tbl = statstr( CArray )

tbl = statstr( table )

tbl = statstr( num1, num2, num3, ... )

bullet.gif    The returned value tbl contains the following 8 values:

bullet.gif      tbl["mean"] is the mean value.

bullet.gif      tbl["median"] is the median value.

bullet.gif      tbl["sdev"] is the standard deviation.

bullet.gif      tbl["min"] is the minimum value.

bullet.gif      tbl["max"] is the maximum value.

bullet.gif      tbl["skewness"] is the statistical skewness.

bullet.gif      tbl["kurtosis"] is the statistical kurtosis.

bullet.gif      tbl["count"] is the number of values in the sample.

bullet.gif    On success, tbl is returned.

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 = statstr( I, new_rect(10,30,15,35) )

-- computes values inside the CRect

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

-- list the result

The next script calculates basic statistics for a series of 4 numbers:

t = statstr(1.5, 2.5, "3.5", 4.5)

-- compute stats for 4 numbers

Printf("mean = %lg +/- %lg\n", t["mean"], t["sdev"] )

--mean = 3.0 +/- 1.29099

Related Topics

Table and Array Functions

CStats class

CStats:Stats

CImage class

CRect class

stats

mean

sdev


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