Skip to main content
Module

x/statistics/src/harmonic_mean.ts>harmonicMean

Deno basic statistics module.
Latest
function harmonicMean
import { harmonicMean } from "https://deno.land/x/statistics@v0.1.1/src/harmonic_mean.ts";

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 on O(n), linear time in respect to the array.

Examples

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

Parameters

x: number[]

sample of one or more data points

Returns

number

harmonic mean