summaryrefslogtreecommitdiffstats
path: root/Doc/library/statistics.rst
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2019-04-07 16:20:03 (GMT)
committerGitHub <noreply@github.com>2019-04-07 16:20:03 (GMT)
commit6463ba3061bd311413d2951dc83c565907e10459 (patch)
tree9450cc1c68b6bab42bd81c32901c28055928dfbc /Doc/library/statistics.rst
parent9d7b2c0909b78800d1376fd696f73824ea680463 (diff)
downloadcpython-6463ba3061bd311413d2951dc83c565907e10459.zip
cpython-6463ba3061bd311413d2951dc83c565907e10459.tar.gz
cpython-6463ba3061bd311413d2951dc83c565907e10459.tar.bz2
bpo-27181: Add statistics.geometric_mean() (GH-12638)
Diffstat (limited to 'Doc/library/statistics.rst')
-rw-r--r--Doc/library/statistics.rst19
1 files changed, 19 insertions, 0 deletions
diff --git a/Doc/library/statistics.rst b/Doc/library/statistics.rst
index 1d52d98..8bb2bdf 100644
--- a/Doc/library/statistics.rst
+++ b/Doc/library/statistics.rst
@@ -40,6 +40,7 @@ or sample.
======================= ===============================================================
:func:`mean` Arithmetic mean ("average") of data.
:func:`fmean` Fast, floating point arithmetic mean.
+:func:`geometric_mean` Geometric mean of data.
:func:`harmonic_mean` Harmonic mean of data.
:func:`median` Median (middle value) of data.
:func:`median_low` Low median of data.
@@ -130,6 +131,24 @@ However, for reading convenience, most of the examples show sorted sequences.
.. versionadded:: 3.8
+.. function:: geometric_mean(data)
+
+ Convert *data* to floats and compute the geometric mean.
+
+ Raises a :exc:`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.)
+
+ .. doctest::
+
+ >>> round(geometric_mean([54, 24, 36]), 9)
+ 36.0
+
+ .. versionadded:: 3.8
+
+
.. function:: harmonic_mean(data)
Return the harmonic mean of *data*, a sequence or iterator of