summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2019-01-30 13:30:20 -0800
committerGitHub <noreply@github.com>2019-01-30 13:30:20 -0800
commit40ebe948e97b47fc84c8f527910063286a174b25 (patch)
tree014b392a3e92fcb02dbafdb8080d06bc1bbc5a35
parentcf991e653ac550a9f011631447c61ce583404a57 (diff)
downloadcpython-git-40ebe948e97b47fc84c8f527910063286a174b25.tar.gz
Document differences between random.choices() and random.choice(). (GH-11703)
-rw-r--r--Doc/library/random.rst7
1 files changed, 7 insertions, 0 deletions
diff --git a/Doc/library/random.rst b/Doc/library/random.rst
index 4f251574a3..a543ff016a 100644
--- a/Doc/library/random.rst
+++ b/Doc/library/random.rst
@@ -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