aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorleodema <leodema@users.noreply.github.com>2018-12-24 07:54:25 +0100
committerRaymond Hettinger <rhettinger@users.noreply.github.com>2018-12-23 22:54:25 -0800
commit63d152232e1742660f481c04a811f824b91f6790 (patch)
treed7556879b3d774444c485e791cdcfde274d175e4 /Lib/random.py
parentbpo-35566: Add links to annotation glossary term (GH-11291) (diff)
downloadcpython-63d152232e1742660f481c04a811f824b91f6790.tar.gz
cpython-63d152232e1742660f481c04a811f824b91f6790.tar.bz2
cpython-63d152232e1742660f481c04a811f824b91f6790.zip
bpo-30561: Sync-up expovariate() and gammavariate code (GH-1934)
Diffstat (limited to 'Lib/random.py')
-rw-r--r--Lib/random.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/Lib/random.py b/Lib/random.py
index 9c2904cfd2f..e00a0262389 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -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)