Skip to content

Commit

Permalink
bpo-38382: Document the early-out behavior for a zero (GH-17037)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhettinger authored Nov 7, 2019
1 parent 519cb87 commit 7f46049
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Doc/library/statistics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ However, for reading convenience, most of the examples show sorted sequences.
The harmonic mean, sometimes called the subcontrary mean, is the
reciprocal of the arithmetic :func:`mean` of the reciprocals of the
data. For example, the harmonic mean of three values *a*, *b* and *c*
will be equivalent to ``3/(1/a + 1/b + 1/c)``.
will be equivalent to ``3/(1/a + 1/b + 1/c)``. If one of the values
is zero, the result will be zero.

The harmonic mean is a type of average, a measure of the central
location of the data. It is often appropriate when averaging
Expand All @@ -190,6 +191,10 @@ However, for reading convenience, most of the examples show sorted sequences.
:exc:`StatisticsError` is raised if *data* is empty, or any element
is less than zero.

The current algorithm has an early-out when it encounters a zero
in the input. This means that the subsequent inputs are not tested
for validity. (This behavior may change in the future.)

.. versionadded:: 3.6


Expand Down

0 comments on commit 7f46049

Please # to comment.