summaryrefslogtreecommitdiffstats
path: root/Doc
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
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')
-rw-r--r--Doc/library/statistics.rst19
-rw-r--r--Doc/whatsnew/3.8.rst3
2 files changed, 22 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
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index ac20ee3..4347b3e 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -322,6 +322,9 @@ Added :func:`statistics.fmean` as a faster, floating point variant of
:func:`statistics.mean()`. (Contributed by Raymond Hettinger and
Steven D'Aprano in :issue:`35904`.)
+Added :func:`statistics.geometric_mean()`
+(Contributed by Raymond Hettinger in :issue:`27181`.)
+
Added :func:`statistics.multimode` that returns a list of the most
common values. (Contributed by Raymond Hettinger in :issue:`35892`.)