This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Clarify behaviour of random.uniform
Type: Stage:
Components: Documentation Versions: Python 3.0, Python 3.1, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: georg.brandl, mark.dickinson, rhettinger
Priority: low Keywords:

Created on 2009-06-10 21:30 by mark.dickinson, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg89232 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-06-10 21:30
The documentation for random.uniform() was recently updated to reflect 
the fact that it's possible for random.uniform(a, b) to produce the 
value b;  see issue 4979.

In a recent c.l.p. thread, Robert Kern suggested that 'it 
might be confusing to a user why random.random() returns values in a 
half-open interval while random.uniform() claims a closed interval';  
the thread itself confirms this potential for confusion.  See

http://mail.python.org/pipermail/python-list/2009-June/715851.html

Suggested extra wording for random.uniform, from Robert Kern:

"Due to floating point arithmetic, for some values of a and b, b may or 
may not be one of the possible generated results."
msg89233 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-06-10 22:00
Regardless of whether the extra wording is added or not, the docstring for 
random.uniform should probably be changed to match the online 
documentation.  It currently says:

"""Get a random number in the range [a, b)."""

That should probably be:

"""Get a random number in the range [a, b]."""
msg89234 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-06-10 22:03
Right.
msg89266 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-06-11 23:12
Fixed in r73380
History
Date User Action Args
2022-04-11 14:56:50adminsetgithub: 50510
2009-06-11 23:12:42rhettingersetstatus: open -> closed
resolution: fixed
messages: + msg89266

versions: - Python 3.2
2009-06-10 22:03:28rhettingersetmessages: + msg89234
2009-06-10 22:00:40mark.dickinsonsetmessages: + msg89233
2009-06-10 21:40:16rhettingersetpriority: low
assignee: georg.brandl -> rhettinger

nosy: + rhettinger
2009-06-10 21:30:27mark.dickinsoncreate