ismultidim mediann

mediansdevn


The mediansdevn function returns the median value and standard deviation 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 mediann function returns only the medianvalue. The related mediansdev function calculates the median and standard deviation 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

nMedian, nStdDev = mediansdevn( tbl )

bullet.gif    tbl is a general lua table.

bullet.gif    nMeian is the median value of the data.

bullet.gif    nStdDev is the standard deviation of the data.

Examples

The following script returns the median and standard deviation of a 1-dimensional array containing 1 million random numbers.

t = random( 1000000 )

-- create an array of numbers

v, s = mediansdevn( t )

-- find the median & standard deviation

Printf("Median=%lg, Sdev = %lg\n", v, s )

-- list the result

  

The next example computes the median and standard deviation of an ugly, complex table:

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

 

v, s = mediansdevn(t)

-- find the meian and standard deviation

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

-- result: M = 5.5, based on only 4 numbers

Related Topics

Table and Array Functions

mediann

meann

sdevn

meansdev

 

 


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