harmeansdevn
The harmeansdevn function returns the harmonic mean value 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 harmeann 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.
nHarMean, nStdDev = harmeansdevn( tbl )
tbl is a general lua table.
nHarMean is the harmonic mean of the table.
nStdDev is the standard deviation of the data.
The following script returns the harmonic mean and standard deviation of a 1-dimensional array containing 1 million random numbers.
|
-- create an array of numbers |
|
-- find the harmonic mean & standard deviation |
|
-- list the result |
The next example computes the harmonic mean and standard deviation of an ugly, complex table:
|
|
|
-- find the harmonic mean and standard deviation |
Table and Array Functions, harmeann, meann
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.