summaryrefslogtreecommitdiffstats
path: root/Doc/library/statistics.rst
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2019-02-21 23:06:29 (GMT)
committerGitHub <noreply@github.com>2019-02-21 23:06:29 (GMT)
commit47d9987247bcc45983a6d51fd1ae46d5d356d0f8 (patch)
tree16b7e88590f9a28ff47e8a0e041510c4a2d86756 /Doc/library/statistics.rst
parentf36f89257b30e0bf88e8aaff6da14a9a96f57b9e (diff)
downloadcpython-47d9987247bcc45983a6d51fd1ae46d5d356d0f8.zip
cpython-47d9987247bcc45983a6d51fd1ae46d5d356d0f8.tar.gz
cpython-47d9987247bcc45983a6d51fd1ae46d5d356d0f8.tar.bz2
bpo-35904: Add statistics.fmean() (GH-11892)
Diffstat (limited to 'Doc/library/statistics.rst')
-rw-r--r--Doc/library/statistics.rst18
1 files changed, 18 insertions, 0 deletions
diff --git a/Doc/library/statistics.rst b/Doc/library/statistics.rst
index 26bb592..20a2c1c 100644
--- a/Doc/library/statistics.rst
+++ b/Doc/library/statistics.rst
@@ -39,6 +39,7 @@ or sample.
======================= =============================================
:func:`mean` Arithmetic mean ("average") of data.
+:func:`fmean` Fast, floating point arithmetic mean.
:func:`harmonic_mean` Harmonic mean of data.
:func:`median` Median (middle value) of data.
:func:`median_low` Low median of data.
@@ -111,6 +112,23 @@ However, for reading convenience, most of the examples show sorted sequences.
``mean(data)`` is equivalent to calculating the true population mean μ.
+.. function:: fmean(data)
+
+ Convert *data* to floats and compute the arithmetic mean.
+
+ This runs faster than the :func:`mean` function and it always returns a
+ :class:`float`. The result is highly accurate but not as perfect as
+ :func:`mean`. If the input dataset is empty, raises a
+ :exc:`StatisticsError`.
+
+ .. doctest::
+
+ >>> fmean([3.5, 4.0, 5.25])
+ 4.25
+
+ .. versionadded:: 3.8
+
+
.. function:: harmonic_mean(data)
Return the harmonic mean of *data*, a sequence or iterator of