New submission from FH:
Upon inspection, random.randint(a,b) does not include the endpoint b, contrary
to documentation, and contrary to the argumentation in Issue7009.
To see this, run e.g.
sum(np.random.randint(0,1,1000))
which will return 0 repeatedly (statistically very unlikely). I tried both on
Kubuntu 14.04/python 2.7 and pythoneverwhere.org
Within random.py, randint is (in both 2.7 and 3.5) implemented as
def randint(self, a, b):
"""Return random integer in range [a, b], including both end points.
"""
return self.randrange(a, b+1)
which falsely seems to include the endpoint (as randrange excludes the
endpoint). However, upon running it does not.
----------
components: Library (Lib)
messages: 229765
nosy: georg.brandl, orsenthil, sciencebuggy
priority: normal
severity: normal
status: open
title: random.randint does not include endpoint
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue22686>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com