Skip to content

test: guard the p-value tail against 1 - cdf coming back - #36

Merged
stefan-jansen merged 4 commits into
mainfrom
test/pvalue-tail-detector
Aug 12, 2026
Merged

test: guard the p-value tail against 1 - cdf coming back#36
stefan-jansen merged 4 commits into
mainfrom
test/pvalue-tail-detector

Conversation

@stefan-jansen

Copy link
Copy Markdown
Contributor

Closes #32.

2 * (1 - dist.cdf(abs(stat))) returns exactly 0.0 once the statistic passes about 8.35, because cdf rounds to 1.0 well before the tail mass underflows. At |t| = 8.94 with df 4231 the true two-tailed value is 5.7e-19 and the expression gives 0. It reached a reader: crypto_perps_funding/02_labels rendered HAC t(3 lags): -8.94 (p=0).

The sources are already fixed on main, by 9f7a72a, not by PR #28. metrics/ic_inference.py:57,283 use stats.t.sf, and neither spelling of the expression appears anywhere in src/. What main does not have is the guard.

What this adds

tests/test_evaluation/test_pvalue_tail_precision.py, taken unchanged from fix/pvalue-survival-function. It pins compute_ic_summary_stats, compute_ic_hac_stats, Ljung-Box and the DSR numerically, and scans the rest statically.

The scan parses rather than greps, because the expression has a second spelling a 1 - <dist>.cdf( pattern cannot see:

probability = float(norm.cdf(z_score))
p_value = float(1 - probability)

It collects the names each file binds to a CDF value and flags 1 - <that name> wherever it appears, so both spellings are covered.

Verification

14 pass against main unmodified, so main is clean. Reintroducing the expression at metrics/ic_inference.py:57 fails three of them - the two numeric pins and the static scan - so the guard is not vacuous.

On PR #28

That branch carries 18 source fixes main has since landed by another route, is CONFLICTING against main, and this file is the only part of it main lacks. It should close unmerged in favour of this.

`2 * (1 - dist.cdf(abs(stat)))` returns exactly 0.0 once the statistic passes
about 8.35, because cdf rounds to 1.0 well before the tail mass underflows. At
|t| = 8.94 with df 4231 the true two-tailed value is 5.7e-19 and the expression
gives 0. It reached a reader: crypto_perps_funding/02_labels rendered
"HAC t(3 lags): -8.94 (p=0)".

The sources were fixed on main by 9f7a72a, and this detector is what stops them
regressing. It pins compute_ic_summary_stats, compute_ic_hac_stats, Ljung-Box
and the DSR numerically, and scans the rest statically. The scan parses rather
than greps, because the expression has a second spelling that a `1 - <dist>.cdf(`
pattern does not see:

    probability = float(norm.cdf(z_score))
    p_value = float(1 - probability)

It collects the names each file binds to a CDF value and flags `1 - <that name>`
wherever it appears, so both spellings are covered.

Verified: 14 passed against main unmodified, so main is clean. Reintroducing the
expression at metrics/ic_inference.py:57 fails three of them - the two numeric
pins and the static scan - so the guard is not vacuous.

Taken from origin/fix/pvalue-survival-function, whose 18 source fixes main has
since landed by another route; that branch is now conflicting and this file is
the only part of it main does not have. PR #28 should close
unmerged in favour of this.
Copilot AI lite review requested due to automatic review settings August 9, 2026 21:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@stefan-jansen stefan-jansen added compatibility: none No known compatibility impact priority: high Material user impact requiring prompt remediation status: accepted Accepted for implementation type: bug Confirmed or reported incorrect behavior labels Aug 11, 2026
@stefan-jansen
stefan-jansen merged commit 1554783 into main Aug 12, 2026
36 checks passed
@stefan-jansen
stefan-jansen deleted the test/pvalue-tail-detector branch August 12, 2026 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compatibility: none No known compatibility impact priority: high Material user impact requiring prompt remediation status: accepted Accepted for implementation type: bug Confirmed or reported incorrect behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The 1 - cdf tail underflow is fixed on main but nothing guards it, and PR #28 which carries the guard is stale

2 participants