Table and Array Functions addn

Table Functions


These functions work with general multi-dimensional tables that contain sub-tables within the primary table. They also support tables with or without keys and with any type of values. Their names have an extra "n" appended to signify that they support table with higher dimensions. Most are generalizations of the Array Functions that support 1-dimensional arrays (indexed tables). However, none of these table functions support either class objects, like CImage, or lists of numbers. Most functions perform some type of mathematical processing by selecting only the numeric values in the table.

Several of the table functions return the processed table which can become the input of another function. For example, the following table equation is possible: x = meann( muln( addn( tbl, 20.5), 0.42 ) )). This adds 20.5 to all numeric value in table tbl, then multiples that by 0.42, then calculates the mean value x.

These functions create the possibility of mixing the numeric data of a 1-dimensional indexed array with non-numerc data that describes the data in the array. This works because lua tables are a general structuring element that can contain nearly any type of data. These functions can then be used to operate on the purely numeric data while leaving the keyed data intact. For example, consider the following table which contains two keys, name and cval:

     t = { 6, -2, 15, name="my identifier", cval="5.4", 5.04 }

Applying the table function sumn(t) returns the sum of numeric elements, which is 24.04. Similarly, t2 = addn(t,4.5) gives the following result:

     t2 = { 10.5, 2.5, 19.5, name="my identifier", cval="5.4", 9.54 }

Table Functions

addn

Adds a number to the numeric values in a general table.

divn

Divides a number into the numeric values in a general table.

flatten

Flattens the numeric values of a general table into a 1-dimensional array

flattenn

Flattens all values of a general table into a 1-dimensional array

harmeann

Calculates the harmonic mean of the numeric values in a general table.

harmeansdevn

Calculates the harmonic mean and standard deviation of the numeric values in a general table.

ismultidim

Returns true of the specified table has more than one dimension (i.e., contains at least on sub-table).

list

Lists the contents of a table.

maxn

Returns the maximum value in a general table.

meann

Returns the mean for the numeric values in a general table

meansdevn

Returns the mean and standard deviation for the numeric values in a general table

mediann

Returns the median for the numeric values in a general table.

mediansdevn

Returns the median and standard deviation for the numeric values in a general table.

minn

Returns the minimum value of the numeric values in a general table.

muln

Multiples the numeric values in a general table by a specified number.

normn

Normalizes the numeric values in a general table so their sum is 1.0.

rankn

Returns the specified rank value for numeric values in a general table.

sdevn

Returns the standard deviation of numeric values in a general table.

sdevxn

Returns the standard deviation about a specified value for a general table.

subn

Subtracts a number from the numeric values of a general table.

sumn

Returns the sum of numeric values in a general table.

tcountn

Returns the count of numeric elements in a general table.

xdivn

Divided each member of a general table into a specified number. This is often called "reverse division."

Related Topics

Contents

Table and Array Functions

Array Functions


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