bpo-30561: Sync-up expovariate() and gammavariate code (GH-1934)

This commit is contained in:
leodema 2018-12-24 07:54:25 +01:00 committed by Raymond Hettinger
parent b7105c9c96
commit 63d152232e
3 changed files with 38 additions and 17 deletions

View file

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