|
sdevxn
The sdevxn function returns the standard
deviation about a specified mean value for a general lua table that
may contain a multi-dimensional array or a mixture of numbers,
strings, named keys, and sub-tables. This differs from the ordinary
standard deviation which calculates the standard deviation about
the mean value.
Note that specifying the mean value changes the
number of degrees of freedom from n-1 for the ordinary
standard deviation to n for this calculation, and this leads
to a different result. Since the ordinary standard deviation
minimizes the deviation about the calculated (optimal) mean value,
the smallest standard deviation should result from calculating the
ordinary standard deviation. Be wary of getting sporadic results
from small samples. A smaller sample size has less statistical
significance and may actually produce a standard deviation that is
smaller than from the ordinary calculation. See the examples
below.
Only numeric values found in the table are used in
the calculation. If the mean value is not specified use
sdevn to calculate the ordinary standard deviation of
a general table.
The related
sdev function calculates the mean of a 1-dimensional
array,
CImage, or list of numbers.
Syntax
nStdDev = sdevxn( tbl, val )
tbl is a general lua
table.
val is the target value about which the standad
deviation is calculated.
nStdDev is the
standard deviation of the values.
Examples
The following script returns the standard deviation
of a table containing 1 million random numbers.
|
t = random( 1000000 )
|
|
|
sd = sdevn( t )
|
|
|
sdx = sdevxn( t, 0.6
)
|
|
|
Printf("sd=%lg, sdx=%lg\n", sd, sdx
)
|
|
|
|
|
The next example computes the standard deviation
about the vale 7 for an ugly, complex table:
|
t = { 6, -2, 15, "a", {5,"b"},
c="5.4" }
|
|
|
sd = sdevn(t)
|
|
|
sdx = sdevxn(t, 7)
|
|
|
Printf("sd=%lg, sdx=%lg\n", sd, sdx
)
|
|
|
|
|
Related Topics
Table and Array Functions
sdevn
meansdevn
sdev
Mira Pro x64 Script User's Guide, v.8.76 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.
|