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.
Parameters
Section titled “Parameters”number[]
sample of one or more data points
Returns
Section titled “Returns”number
harmonic mean
Throws
Section titled “Throws”if x is empty
Throws
Section titled “Throws”if x contains a negative number
Example
Section titled “Example”harmonicMean([2, 3]).toFixed(2) // => '2.40'