ID EN
Statistics

harmonic_mean

Python 3.11

Return the harmonic mean of data, a sequence or iterable of real-valued numbers. If weights is omitted or None, then equal weighting is assumed.

Syntax

PYTHON
statistics.harmonic_mean(data, weights=None)

Examples

Example 1
PYTHON
>>> harmonic_mean([40, 60])
48.0
Example 2
PYTHON
>>> harmonic_mean([40, 60], weights=[5, 30])
56.0

See Also

mean() StatisticsError