STANDARD-DEVIATION Function [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation
HP COBOL II/XL Reference Manual
STANDARD-DEVIATION Function
The STANDARD-DEVIATION function returns a numeric value that approximates
the standard deviation of its arguments. The function type is numeric.
Syntax
FUNCTION STANDARD-DEVIATION ({parameter-1}...)
Parameters
parameter-1 Must be class numeric.
Return Value
The returned value is the approximation of the standard deviation of the
parameter-1 series.
The returned value is calculated as follows:
1. The difference between each parameter-1 value and the arithmetic
mean of the parameter-1 series is calculated and squared.
2. The values obtained are added together. This quantity is divided
by the number of values in the parameter-1 series.
3. The square root of the quotient obtained is calculated. The
returned value is the absolute value of this square root.
If the parameter-1 series consists of only one value, or if the
parameter-1 series consists of all variable occurrence data items and the
total number of occurrences for all of them is one, the returned value is
zero.
Example
01 TAB.
05 ELEMENT PIC S999V99
OCCURS 4 TIMES VALUE ZERO.
01 NUM-STD-DEV PIC S999V99 VALUE ZERO.
:
MOVE 1.25 TO ELEMENT (1).
MOVE 3.50 TO ELEMENT (2).
MOVE 8.75 TO ELEMENT (3).
MOVE 0.25 TO ELEMENT (4).
COMPUTE NUM-STD-DEV = FUNCTION STANDARD-DEVIATION (1, 7, 9, 23, 85).
DISPLAY NUM-STD-DEV.
COMPUTE NUM-STD-DEV = FUNCTION STANDARD-DEVIATION ( ELEMENT (ALL) ).
DISPLAY NUM-STD-DEV.
The above example displays the following:
+030.85
+003.28
MPE/iX 5.0 Documentation