HARMEANZ Function

Returns the harmonic mean, using zero fuzzing.

Category: Descriptive Statistics
Returned data type: DOUBLE

Syntax

HARMEANZ(expression [, ...expression])

Arguments

expression

specifies any valid expression that evaluates to a nonnegative numeric value.

Data type DOUBLE
See <sql-expression>
FedSQL Expressions

Details

If any argument is negative, then the result is a null or value. A message appears in the log that the negative argument is invalid. If all the arguments are null or values, then the result is a null or value. Otherwise, the result is the harmonic mean of the non-null or nonmissing values.
If any argument is zero, then the harmonic mean is zero. Otherwise, the harmonic mean is the reciprocal of the arithmetic mean of the reciprocals of the values.
Let n  be the number of arguments with non-null or nonmissing values, and let x sub 1 , comma , x sub 2 , comma dot dot dot comma , x sub n  be the values of those arguments. The harmonic mean is shown in this equation.
table with 1 row and 1 column , row1 column 1 , fraction n , over fraction 1 , over x sub 1 end fraction , plus , fraction 1 , over x sub 2 end fraction , plus dot dot dot plus , fraction 1 , over x sub n end fraction end fraction , end table

Comparisons

The MEAN function returns the arithmetic mean (average), and the GEOMEAN function returns the geometric mean, whereas the HARMEANZ function returns the harmonic mean of the non-null or nonmissing values. Unlike HARMEAN, HARMEANZ does not fuzz the values of the arguments that are approximately zero.

Example

The following statements illustrate the HARMEANZ function:
Statements
Results
select harmeanz(1,2,4,4);
2
select harmeanz(.,4,12,24);
8