mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
Code simplification suggested by Sven Marnach.
This commit is contained in:
parent
cb9bf1ac9c
commit
cba87311d2
1 changed files with 3 additions and 5 deletions
|
@ -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 --------------------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue