Language Reference


HARMEAN Function

HARMEAN (matrix);

The HARMEAN function returns a scalar that contains the harmonic mean of the elements of the input matrix. The input matrix must contain only nonnegative numbers. The harmonic mean of a set of positive numbers $a_1, a_2,\ldots ,a_ n$ is n divided by the sum of the reciprocals of $a_ i$. That is, $n / \sum a_ i^{-1}$.

The harmonic mean is zero if any of the $a_ i$ are zero. The harmonic mean is not defined for negative numbers. If any of the $a_ i$ are missing, they are excluded from the computation.

The harmonic mean is sometimes used to compute an average sample size in an unbalanced experimental design. For example, the following statements compute an average sample size for five samples:

sizes = { 8, 12, 23, 10, 8 }; /* sample sizes */
aveSize = harmean( sizes );
print aveSize;

Figure 24.154: Harmonic Mean

aveSize
10.486322