[Python-checkins] cpython (merge 2.7 -> 2.7): merge

mark.dickinson python-checkins at python.org
Sat Jun 25 12:02:59 CEST 2011


http://hg.python.org/cpython/rev/183621c377ef
changeset: 70960:183621c377ef
branch: 2.7
parent: 70959:d912dfb7ab7a
parent: 70948:4970fa3c4a0b
user: Mark Dickinson <mdickinson at enthought.com>
date: Sat Jun 25 12:02:53 2011 +0200
summary:
 merge
files:
 Lib/random.py | 8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/Lib/random.py b/Lib/random.py
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -427,11 +427,9 @@
 # lambd: rate lambd = 1/mean
 # ('lambda' is a Python reserved word)
 
- random = self.random
- u = random()
- while u <= 1e-7:
- u = random()
- return -_log(u)/lambd
+ # we use 1-random() instead of random() to preclude the
+ # possibility of taking the log of zero.
+ return -_log(1.0 - self.random())/lambd
 
 ## -------------------- von Mises distribution --------------------
 
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /