-
Notifications
You must be signed in to change notification settings - Fork 15
/
qerf.py
48 lines (34 loc) · 762 Bytes
/
qerf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import math
def qerf(z):
"""
The standard normal complementary probability - see function in
C. Hastings, Jr. (1955). The maximum error should be 7.5x10^-8.
Parameters
----------
z : TODO: Type
TODO: Description
Output
------
qerf1 : float
TODO:
"""
b1 = 0.319381530
b2 = -0.356563782
b3 = 1.781477937
b4 = -1.821255987
b5 = 1.330274429
rp = 4.317008
rrt2pi = 0.398942280
x = z
t = abs(x)
if t >= 10:
qerf1 = 0
else:
t = rp / (t + rp)
qerf1 = (
math.exp(-0.5 * x**2) * rrt2pi *
((((b5 * t + b4) * t + b3) * t + b2) * t + b1) * t
)
if x < 0:
qerf1 = 1 - qerf1
return qerf1