]> granicus.if.org Git - python/commitdiff
random_triangular: sqrt() is more accurate than **0.5 (#3317)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Mon, 4 Sep 2017 23:51:06 +0000 (16:51 -0700)
committerGitHub <noreply@github.com>
Mon, 4 Sep 2017 23:51:06 +0000 (16:51 -0700)
Lib/random.py

index e1c2c2bbcbe06682d830d5cea6bad2ddaa10e3c3..01c0c3d25fb519e55774fdd613b9d02d6053a883 100644 (file)
@@ -388,7 +388,7 @@ class Random(_random.Random):
             u = 1.0 - u
             c = 1.0 - c
             low, high = high, low
-        return low + (high - low) * (u * c) ** 0.5
+        return low + (high - low) * _sqrt(u * c)
 
 ## -------------------- normal distribution --------------------