Skip to content

Commit

Permalink
Document differences between random.choices() and random.choice(). (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
rhettinger committed Jan 30, 2019
1 parent cf991e6 commit 40ebe94
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Doc/library/random.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ Functions for sequences
with the :class:`float` values returned by :func:`random` (that includes
integers, floats, and fractions but excludes decimals).

For a given seed, the :func:`choices` function with equal weighting
typically produces a different sequence than repeated calls to
:func:`choice`. The algorithm used by :func:`choices` uses floating
point arithmetic for internal consistency and speed. The algorithm used
by :func:`choice` defaults to integer arithmetic with repeated selections
to avoid small biases from round-off error.

.. versionadded:: 3.6


Expand Down

0 comments on commit 40ebe94

Please sign in to comment.