random_triangular: sqrt() is more accurate than **0.5 (#3317) · python/cpython@f5ea83f

Original file line numberDiff line numberDiff line change

@@ -388,7 +388,7 @@ def triangular(self, low=0.0, high=1.0, mode=None):

388388

u = 1.0 - u

389389

c = 1.0 - c

390390

low, high = high, low

391-

return low + (high - low) * (u * c) ** 0.5

391+

return low + (high - low) * _sqrt(u * c)

392392
393393

## -------------------- normal distribution --------------------

394394