mediann
The mediann function returns the median 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 mediansdevn function returns both the median and standard deviation. The related median function calculates the median 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.
nMedian = mediann( tbl )
    tbl is a
general lua table.
    nMedian is the median value of the
table.
The following script returns the median of a 1-dimensional array containing 1 million random numbers.
| 
 | 
 -- create an array of numbers  | 
| 
 | 
 -- find the median & standard deviation  | 
| 
 | 
 -- list the result  | 
The next example computes the median of an ugly, complex table:
| 
 | 
 
  | 
| 
 | 
 -- find the median and standard deviation  | 
| 
 | 
 -- result: Median = 5.5, based on only 4 numbers  | 
Table and Array Functions, mediansdevn, rankn, meann, sdevn, meansdev
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.