summaryrefslogtreecommitdiffstats
path: root/Lib/random.py
diff options
context:
space:
mode:
authorleodema <leodema@users.noreply.github.com>2018-12-24 06:54:25 (GMT)
committerRaymond Hettinger <rhettinger@users.noreply.github.com>2018-12-24 06:54:25 (GMT)
commit63d152232e1742660f481c04a811f824b91f6790 (patch)
treed7556879b3d774444c485e791cdcfde274d175e4 /Lib/random.py
parentb7105c9c9663637e4500bfcac75c911e78d9a1c0 (diff)
downloadcpython-63d152232e1742660f481c04a811f824b91f6790.zip
cpython-63d152232e1742660f481c04a811f824b91f6790.tar.gz
cpython-63d152232e1742660f481c04a811f824b91f6790.tar.bz2
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 9c2904c..e00a026 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)