@@ -37,6 +37,27 @@ def test_separated_groups_are_significant_and_ci_excludes_zero():
3737 assert rep ["ci_low" ] <= rep ["gap" ] <= rep ["ci_high" ]
3838
3939
40+ def test_confidence_tightens_the_significance_threshold_not_just_the_ci ():
41+ # A gap with 0.01 < p < 0.05 is significant at the default confidence
42+ # (0.95 -> p < 0.05) but not at confidence=0.99 (-> p < 0.01). Before
43+ # #548 the `significant` flag was pinned to p < 0.05 regardless of
44+ # `confidence`, which only widened/narrowed the CI.
45+ rng = np .random .default_rng (0 )
46+ for _ in range (5 ):
47+ a = rng .binomial (1 , 0.55 , size = 60 ).astype (float )
48+ b = rng .binomial (1 , 0.35 , size = 60 ).astype (float )
49+
50+ r95 = significance_report (a , b , n_resamples = 3000 , n_permutations = 3000 ,
51+ confidence = 0.95 , random_state = 4 )
52+ r99 = significance_report (a , b , n_resamples = 3000 , n_permutations = 3000 ,
53+ confidence = 0.99 , random_state = 4 )
54+
55+ assert r95 ["p_value" ] == r99 ["p_value" ] # same permutation test
56+ assert 0.01 < r95 ["p_value" ] < 0.05
57+ assert r95 ["significant" ] is True
58+ assert r99 ["significant" ] is False
59+
60+
4061# ── Determinism ──────────────────────────────────────────────────────────────
4162def test_random_state_makes_results_deterministic ():
4263 a = [1 ] * 40 + [0 ] * 60
0 commit comments