MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / geometric_mean

Function geometric_mean

tools/python-3.11.9-amd64/Lib/statistics.py:474–490  ·  view source on GitHub ↗

Convert data to floats and compute the geometric mean. Raises a StatisticsError if the input dataset is empty, if it contains a zero, or if it contains a negative value. No special efforts are made to achieve exact results. (However, this may change in the future.) >>>

(data)

Source from the content-addressed store, hash-verified

472
473
474def geometric_mean(data):
475 """Convert data to floats and compute the geometric mean.
476
477 Raises a StatisticsError if the input dataset is empty,
478 if it contains a zero, or if it contains a negative value.
479
480 No special efforts are made to achieve exact results.
481 (However, this may change in the future.)
482
483 >>> round(geometric_mean([54, 24, 36]), 9)
484 36.0
485 """
486 try:
487 return exp(fmean(map(log, data)))
488 except ValueError:
489 raise StatisticsError('geometric mean requires a non-empty dataset '
490 'containing positive numbers') from None
491
492
493def harmonic_mean(data, weights=None):

Callers

nothing calls this directly

Calls 3

fmeanFunction · 0.85
StatisticsErrorClass · 0.85
mapFunction · 0.50

Tested by

no test coverage detected