HP 3000 Manuals

MEAN Function [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation


HP COBOL II/XL Reference Manual

MEAN Function 

The MEAN function returns a numeric value that is the arithmetic mean
(average) of its parameters.  The function type is numeric.

Syntax 

     FUNCTION MEAN ({parameter-1}...)

Parameters 

parameter-1           Must be class numeric.

Return Value 

The value returned is the arithmetic mean of the parameter-1 series.

The value returned is defined as the sum of the parameter-1 series
divided by the number of occurrences referenced by parameter-1.

Example 

     01  TAB.
         05  ELEMENT   PIC S999V99
                         OCCURS 4 TIMES VALUE ZERO.
     01  MEAN-VALUE    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 MEAN-VALUE = FUNCTION MEAN (1 7 9 23 85)
     DISPLAY MEAN-VALUE
     COMPUTE MEAN-VALUE = FUNCTION MEAN ( ELEMENT (ALL) )
     DISPLAY MEAN-VALUE

The above example displays the following:

     +025.00
     +003.43



MPE/iX 5.0 Documentation