VARIANCE Function [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation
HP COBOL II/XL Reference Manual
VARIANCE Function
The VARIANCE function returns a numeric value that approximates the
variance of its parameters. The function type is numeric.
Syntax
FUNCTION VARIANCE ({parameter-1}...)
Parameters
parameter-1 Must be class numeric.
Return Value
The returned value is the approximation of the variance of the
parameter-1 series.
The returned value is defined as the square of the standard deviation of
the parameter-1 series. See the description of the STANDARD-DEVIATION
function in this chapter for additional information.
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-VARIANCE 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-VARIANCE = FUNCTION VARIANCE (1, 7, 9, 23, 85).
DISPLAY NUM-VARIANCE.
COMPUTE NUM-VARIANCE = FUNCTION VARIANCE ( ELEMENT (ALL) ).
DISPLAY NUM-VARIANCE.
The above example displays the following:
+952.00
+010.79
MPE/iX 5.0 Documentation