the-stack-go / stackgo /tests /test_repoinfo_hoeffding.py
s0duku's picture
Add end-to-end stackgo pipeline
f764cdf verified
Raw History Blame Contribute Delete
745 Bytes
import math
from tests.audit_repoinfo_hoeffding import hoeffding_radius, required_sample_size
def test_hoeffding_sample_size_for_90_90():
assert required_sample_size(0.90, 0.10) == 150
assert hoeffding_radius(150, 0.90) <= 0.10
def test_perfect_sample_proves_90_percent_lower_bound():
lower_bound = 1.0 - hoeffding_radius(150, 0.90)
assert lower_bound >= 0.90
assert math.isclose(lower_bound, 0.9000711540886218)
def test_hoeffding_arguments_are_validated():
for confidence, margin in ((0.0, 0.1), (1.0, 0.1), (0.9, 0.0), (0.9, 1.0)):
try:
required_sample_size(confidence, margin)
except ValueError:
pass
else:
raise AssertionError((confidence, margin))