Kaydet (Commit) be40db07 authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Issue 6261: Clarify behavior of random.uniform().

üst 59e6eb1c
......@@ -142,6 +142,8 @@ be found in any statistics text.
Return a random floating point number *N* such that ``a <= N <= b`` for
``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)
......
......@@ -333,7 +333,7 @@ class Random(_random.Random):
## -------------------- uniform distribution -------------------
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()
## -------------------- triangular --------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment