Code simplification suggested by Sven Marnach.

This commit is contained in:
Raymond Hettinger 2011-06-25 11:31:46 +02:00
commit 12fb2f41f0
1 changed files with 3 additions and 5 deletions

View File

@ -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 --------------------