meann


The meann function returns the meanvalue of a general lua table that may contain non-numeric values, named keys, and sub-tables. Only numeric values found in the table are used in the calculation. The meansdevn function returns both tthe mean value and standard deviation. The related mean function calculates the mean of a 1-dimensional array, CImage, or list of numbers. Since an array is a specific type of table that contains only numbers or sub-tables, this function can also be used for arrays.

Syntax

nMean = meann( tbl )

bullet.gif    tbl is a general lua table.

bullet.gif    nMean is the mean value of the data.

Examples

The following script returns the mean value of a 1-dimensional array containing 1 million random numbers.

t = random( 1000000 )

-- create an array of numbers

v = meann( t )

-- find the mean value

Printf("Mean=%lg\n", v )

-- list the result

  

The next example computes the mean value of an ugly, complex table:

t = { 6, -2, 15, "a", {5,"b"}, c="5.4" }

 

v = meann(t)

-- find the mean value

Printf("M= %lg\n", v )

-- result: Mean = 6, based on only 4 numbers

Related Topics

Table and Array Functions, meansdevn, mediann, sdevn, meansdev, harmeann


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