Skip to content

Commit

Permalink
Merge pull request #10 from edwardoughton/enhance_tests
Browse files Browse the repository at this point in the history
Enhance tests
  • Loading branch information
edwardoughton committed Dec 6, 2019
2 parents b6f9cc4 + 6829046 commit 91043e0
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
23 changes: 13 additions & 10 deletions src/itmlogic/qerf.py
@@ -1,20 +1,22 @@
import math

def qerf(z):
"""
The standard normal complementary probability - see function in
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
Expand All @@ -24,22 +26,23 @@ def qerf(z):

rrt2pi = 0.398942280

x = z[0]
x = z
t = abs(x)

if t >= 10:

qerf1 = 0

else:

t = rp / (t + rp)

qerf1 = (
exp(-0.5 * x**2) * rrt2pi *
math.exp(-0.5 * x**2) * rrt2pi *
((((b5 * t + b4) * t + b3) * t + b2) * t + b1) * t
)

# if (x<0.) qerf1=1.-qerf1 TODO:
if x < 0:
qerf1 = 1 - qerf1

return qerf1
return qerf1
5 changes: 2 additions & 3 deletions tests/test_aknfe.py
Expand Up @@ -3,8 +3,7 @@

def test_aknfe():

assert round(aknfe(2), 2) == 16.36
assert round(aknfe(3), 2) == 17.99
assert round(aknfe(5), 2) == 20.04
assert round(aknfe(6), 2) == 20.73



3 changes: 2 additions & 1 deletion tests/test_fht.py
Expand Up @@ -12,5 +12,6 @@ def test_fht():

assert actual_answer == expected_answer

assert round(fht(150, 20), 2) == 11.05


assert round(fht(150, 1e-6), 2) == -29.96
8 changes: 8 additions & 0 deletions tests/test_h0f.py
Expand Up @@ -12,3 +12,11 @@ def test_h0f():
expected_answer = 34.28154717133048

assert actual_answer == expected_answer

actual_answer = h0f(2, -1)

assert round(actual_answer, 2) == 9.33

actual_answer = h0f(2, 6)

assert round(actual_answer, 2) == 18.53
6 changes: 5 additions & 1 deletion tests/test_qerf.py
@@ -1,4 +1,8 @@
import pytest
from itmlogic.qerf import qerf

# def test_qerf():
def test_qerf():

assert round(qerf(-1),4) == 0.8413
assert round(qerf(1),4) == 0.1587
assert round(qerf(10),4) == 0

0 comments on commit 91043e0

Please sign in to comment.