flattenn harmeansdevn

harmeann


The harmeann function returns the harmonic mean value of a general lua table that may contain a multi-dimensional array or a mixture of numbers, strings, named keys, and sub-tables. Only numeric values found in the table are used in the calculation. The harmeansdevn function returns both the harmonic mean and standard deviation. 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

nHarMean, nStdDev = harmeann( tbl )

bullet.gif    tbl is a general lua table.

bullet.gif    nHarMean is the harmonic mean of the table.

Examples

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

t = random( 1000000 )

-- create an array of numbers

v = harmeann( t )

-- find the harmonic mean

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

-- list the result

  

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

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

 

v = harmeann(t)

-- find the harmonic mean

Related Topics

Table and Array Functions

harmeansdevn

meann

meansdevn

mediann

sdevn

 


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