mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
bpo-30561: Sync-up expovariate() and gammavariate code (GH-1934)
This commit is contained in:
parent
b7105c9c96
commit
63d152232e
3 changed files with 38 additions and 17 deletions
|
@ -582,10 +582,7 @@ class Random(_random.Random):
|
|||
|
||||
elif alpha == 1.0:
|
||||
# expovariate(1/beta)
|
||||
u = random()
|
||||
while u <= 1e-7:
|
||||
u = random()
|
||||
return -_log(u) * beta
|
||||
return -_log(1.0 - random()) * beta
|
||||
|
||||
else: # alpha is between 0 and 1 (exclusive)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue