Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1db37f3 + 5279fb9 commit 12fb2f4Copy full SHA for 12fb2f4
1 file changed
Lib/random.py
@@ -402,11 +402,9 @@ def expovariate(self, lambd):
402
# lambd: rate lambd = 1/mean
403
# ('lambda' is a Python reserved word)
404
405
- random = self.random
406
- u = random()
407
- while u <= 1e-7:
408
409
- 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
410
411
## -------------------- von Mises distribution --------------------
412
0 commit comments