Skip to content

harmonicMean

harmonicMean(x): number

Defined in: src/harmonic_mean.js:19

The Harmonic Mean is a mean function typically used to find the average of rates. This mean is calculated by taking the reciprocal of the arithmetic mean of the reciprocals of the input numbers.

This is a measure of central tendency: a method of finding a typical or central value of a set of numbers.

This runs in O(n), linear time, with respect to the length of the array.

number[]

sample of one or more data points

number

harmonic mean

if x is empty

if x contains a negative number

harmonicMean([2, 3]).toFixed(2) // => '2.40'