From: Raymond Hettinger Date: Mon, 4 Sep 2017 23:51:06 +0000 (-0700) Subject: random_triangular: sqrt() is more accurate than **0.5 (#3317) X-Git-Tag: v3.7.0a1~162 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f5ea83f4864232fecc042ff0d1c2401807b19280;p=python random_triangular: sqrt() is more accurate than **0.5 (#3317) --- diff --git a/Lib/random.py b/Lib/random.py index e1c2c2bbcb..01c0c3d25f 100644 --- a/Lib/random.py +++ b/Lib/random.py @@ -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 --------------------