statistics.harmonic_mean

Full name
statistics.harmonic_mean
Library
statistics
Syntax

statistics.harmonic_mean(data)

Description

The statistics.harmonic_mean function returns the harmonic mean of the elements in data:

statistics.harmonic_mean
Parameters
  • data: Sequence or iterable from whose elements you want to calculate the harmonic mean.
Result

The statistics.harmonic_mean function returns a float.

Examples

We can obtain the harmonic mean of the numbers contained in a list with the following code:

a = [5, 8, 1, 9, 2]
statistics.harmonic_mean(a)
2.582496413199426
Submitted by admin on Thu, 03/25/2021 - 08:40