summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2011-06-25 12:02:53 +0200
committerMark Dickinson <mdickinson@enthought.com>2011-06-25 12:02:53 +0200
commit5b0c22ced3e756e56873a8331ff39eedef788992 (patch)
treee1a1ea7267334214f71285b456e9ea10ae965037
parent653a53fb1445fe4973a0444adb61693567329afb (diff)
parentcba87311d2dc395cbc56d00d7161d191ff7375d2 (diff)
downloadcpython-git-5b0c22ced3e756e56873a8331ff39eedef788992.tar.gz
merge
-rw-r--r--Lib/random.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/Lib/random.py b/Lib/random.py
index 987cff16c4..36b956540b 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -427,11 +427,9 @@ class Random(_random.Random):
# 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 --------------------