SIGMA Function
Standard Library function that calculates the standard deviation value of an array. (Optionally, it can also calculate the standard deviation over one dimension of an array as a function of the other dimensions.)
Usage
result = SIGMA(array[, npar, dim])
Input Parameters
array—The array to be processed. This parameter can be of any data type except string.
npar—(optional) The number of parameters. (Default: 0)
dim—(optional) The dimension over which to calculate the standard deviation.
Returned Value
result—The standard deviation of array, or the standard deviation over one dimension of array as a function of dim.
Keywords
None.
Discussion
The SIGMA function is useful in a variety of data and statistical analyses for estimating thresholds and evaluating the significance of variance.
The number of degrees of freedom in SIGMA is equal to the number of elements in array minus the value supplied in the optional npar. In other words:
degrees of freedom = #_of elements_in_array – npar
The degrees of freedom affects the value of the standard deviation. Specifically, the value of the standard deviation varies as one over the square root of the number of degrees of freedom.
If dim is used, then the result of SIGMA is an array with the same dimensions as the input array, except for the dimension specified. Each element in the resulting array is the standard deviation of the corresponding vector in the input array.
The dimension specified in a SIGMA call must be valid for the array passed; otherwise, the input array is returned as the output array.
If array is an array with dimensions of (3,4,5), then the command:
std = SIGMA(array, 2, 1)
is equivalent to the commands:
std = FLTARR(3,5)
FOR j = 0, 4 DO BEGIN
FOR i = 0, 2 DO BEGIN
STD(i, j) = SIGMA(array(i, *, j), 2)
ENDFOR
ENDFOR
Example
y = [1., 5., 9., 3., 10., 4.]
std = SIGMA(y, 1)
PRINT, 'The standard deviation = ', std ; 3.50238
a = FLTARR(3, 3)
a(*, 0) = [2., 2., 2.]
a(*, 1) = [4., 4., 4.]
a(*, 2) = [6., 6., 6.]
PRINT, a
; Print the standard deviation of the column elements.
PRINT, SIGMA(a, 1, 0)
; PV-WAVE prints: 0.00000 0.00000 0.00000
; Print the standard deviation of the row elements.
PRINT, SIGMA(a, 1, 1)
; PV-WAVE prints: 2.00000 2.00000 2.00000
See Also