summaryrefslogtreecommitdiffstats
path: root/Lib/random.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/random.py')
-rw-r--r--Lib/random.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/Lib/random.py b/Lib/random.py
index 59a4052..ccc304d 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -402,11 +402,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 --------------------