text
stringlengths 0
828
|
|---|
Q = [
|
1.32281951154744992508E1,
|
8.67072140885989742329E1,
|
3.54937778887819891062E2,
|
9.75708501743205489753E2,
|
1.82390916687909736289E3,
|
2.24633760818710981792E3,
|
1.65666309194161350182E3,
|
5.57535340817727675546E2,
|
]
|
# approximation for abs(a) >= 8
|
R = [
|
5.64189583547755073984E-1,
|
1.27536670759978104416E0,
|
5.01905042251180477414E0,
|
6.16021097993053585195E0,
|
7.40974269950448939160E0,
|
2.97886665372100240670E0,
|
]
|
S = [
|
2.26052863220117276590E0,
|
9.39603524938001434673E0,
|
1.20489539808096656605E1,
|
1.70814450747565897222E1,
|
9.60896809063285878198E0,
|
3.36907645100081516050E0,
|
]
|
# Shortcut special cases
|
if a == 0:
|
return 1
|
if a >= MAXVAL:
|
return 0
|
if a <= -MAXVAL:
|
return 2
|
x = a
|
if a < 0:
|
x = -a
|
# computationally cheaper to calculate erf for small values, I guess.
|
if x < 1:
|
return 1 - erf(a)
|
z = -a * a
|
z = math.exp(z)
|
if x < 8:
|
p = _polevl(x, P, 8)
|
q = _p1evl(x, Q, 8)
|
else:
|
p = _polevl(x, R, 5)
|
q = _p1evl(x, S, 6)
|
y = (z * p) / q
|
if a < 0:
|
y = 2 - y
|
return y"
|
1031,"def _polevl(x, coefs, N):
|
""""""
|
Port of cephes ``polevl.c``: evaluate polynomial
|
See https://github.com/jeremybarnes/cephes/blob/master/cprob/polevl.c
|
""""""
|
ans = 0
|
power = len(coefs) - 1
|
for coef in coefs:
|
try:
|
ans += coef * x**power
|
except OverflowError:
|
pass
|
power -= 1
|
return ans"
|
1032,"def _ndtri(y):
|
""""""
|
Port of cephes ``ndtri.c``: inverse normal distribution function.
|
See https://github.com/jeremybarnes/cephes/blob/master/cprob/ndtri.c
|
""""""
|
# approximation for 0 <= abs(z - 0.5) <= 3/8
|
P0 = [
|
-5.99633501014107895267E1,
|
9.80010754185999661536E1,
|
-5.66762857469070293439E1,
|
1.39312609387279679503E1,
|
-1.23916583867381258016E0,
|
]
|
Q0 = [
|
1.95448858338141759834E0,
|
4.67627912898881538453E0,
|
8.63602421390890590575E1,
|
-2.25462687854119370527E2,
|
2.00260212380060660359E2,
|
-8.20372256168333339912E1,
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.