There was an error while loading. Please reload this page.
1 parent 60ab407 commit c4a0eeaCopy full SHA for c4a0eea
1 file changed
Lib/statistics.py
@@ -146,7 +146,7 @@
146
from collections import Counter, namedtuple, defaultdict
147
148
_SQRT2 = sqrt(2.0)
149
-_SQRT2PI = sqrt(2.0 * pi)
+_SQRT2PI = float.fromhex('0x1.40d931ff62706p+1') # Correctly rounded sqrt(2*pi)
150
_random = random
151
152
## Exceptions ##############################################################
@@ -821,8 +821,8 @@ def deco(builder):
821
822
@register('normal', 'gauss')
823
def normal_kernel():
824
- sqrt2pi = sqrt(2 * pi)
825
- neg_sqrt2 = -sqrt(2)
+ sqrt2pi = _SQRT2PI
+ neg_sqrt2 = -_SQRT2
826
pdf = lambda t: exp(-1/2 * t * t) / sqrt2pi
827
cdf = lambda t: 1/2 * erfc(t / neg_sqrt2)
828
invcdf = lambda t: _normal_dist_inv_cdf(t, 0.0, 1.0)
0 commit comments