mirror of
https://github.com/python/cpython.git
synced 2025-09-14 12:46:49 +00:00
Issue 6261: Clarify behavior of random.uniform().
This commit is contained in:
parent
4efb5d0b82
commit
2c0cdca564
2 changed files with 3 additions and 1 deletions
|
@ -191,6 +191,8 @@ be found in any statistics text.
|
||||||
Return a random floating point number *N* such that ``a <= N <= b`` for
|
Return a random floating point number *N* such that ``a <= N <= b`` for
|
||||||
``a <= b`` and ``b <= N <= a`` for ``b < a``.
|
``a <= b`` and ``b <= N <= a`` for ``b < a``.
|
||||||
|
|
||||||
|
The end-point value ``b`` may or may not be included in the range
|
||||||
|
depending on floating-point rounding in the equation ``a + (b-a) * random()``.
|
||||||
|
|
||||||
.. function:: triangular(low, high, mode)
|
.. function:: triangular(low, high, mode)
|
||||||
|
|
||||||
|
|
|
@ -349,7 +349,7 @@ class Random(_random.Random):
|
||||||
## -------------------- uniform distribution -------------------
|
## -------------------- uniform distribution -------------------
|
||||||
|
|
||||||
def uniform(self, a, b):
|
def uniform(self, a, b):
|
||||||
"""Get a random number in the range [a, b)."""
|
"Get a random number in the range [a, b) or [a, b] depending on rounding."
|
||||||
return a + (b-a) * self.random()
|
return a + (b-a) * self.random()
|
||||||
|
|
||||||
## -------------------- triangular --------------------
|
## -------------------- triangular --------------------
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue