harmonicMean

Computes the harmonic mean of the values in this iterable.

The harmonic mean is the reciprocal of the arithmetic mean of the reciprocals. It is appropriate for averaging rates or ratios (e.g. speeds, P/E ratios). All values must be positive. Uses compensated summation for the reciprocals.

NaN values propagate through the computation (IEEE 754 semantics): if any element is NaN, the result is NaN. Filter NaN values before calling this function if that is not desired.

Example:

listOf(1.0, 2.0, 4.0).harmonicMean() // 1.7142...

Return

the harmonic mean of the elements.


Computes the harmonic mean of the values in this array.

The harmonic mean is the reciprocal of the arithmetic mean of the reciprocals. It is appropriate for averaging rates or ratios. All values must be positive. Uses compensated summation for the reciprocals.

NaN values propagate through the computation (IEEE 754 semantics): if any element is NaN, the result is NaN. Filter NaN values before calling this function if that is not desired.

Example:

doubleArrayOf(1.0, 2.0, 4.0).harmonicMean() // 1.7142...

Return

the harmonic mean of the array elements.


Computes the harmonic mean of the values in this sequence.

The sequence is materialized internally. See DoubleArray.harmonicMean for details.

Return

the harmonic mean of the elements.