normn


The normn functionnormalizes the values in a general lua table that may contain non-numeric values, named keys, and sub-tables, so that their sum equals 1.0. Only numeric values found in the table are used in the calculation. The related norm function normalizes 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

new_table = normn( table )

bullet.gif    table is a general lua table.

bullet.gif    new_table is the returned table.

Examples

The following script creates a Gaussian normal population of 10,000 numbers with the area under the curve normalized to 1.0.

t = normn( gaussdev(10000) )

-- create a table of 10,000 values and normalize it

  

The next example normalizes an ugly, complex table:

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

 

tnew = normn(t)

-- normalize the table

Related Topics

Table and Array Functions, norm

 


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