Skip to content

Phase 3: extended univariate test battery - #4

Open
jameshoweee wants to merge 1 commit into
jh/phase2-certificationfrom
jh/phase3-univariate
Open

Phase 3: extended univariate test battery#4
jameshoweee wants to merge 1 commit into
jh/phase2-certificationfrom
jh/phase3-univariate

Conversation

@jameshoweee

Copy link
Copy Markdown
Owner

New file univariate_tests.py with 5 tests that close the blind spots in chi-square:

  • tail exceedance: exact binomial at 3-6 sigma thresholds — catches truncation flaws that chi-square's bucket aggregation dilutes
  • sign/half-Gaussian: factorization test detecting sign-magnitude coupling (SHIFT SNARE attack surface)
  • discrete Anderson-Darling (Choulakian-Lockhart-Stephens 1994): tail-weighted EDF test, MC-calibrated
  • higher criticism (Donoho-Jin 2004): near-optimal against sparse alternatives like a single wrong table entry
  • MC calibration helper: generic null-distribution builder for tests without textbook distributions

Integrated into saga.py via run_extended_battery(). Test vectors updated for 3-sigma truncation (detectable) instead of 6-sigma (undetectable at n=10k).

New tests (code/univariate_tests.py):
- Tail exceedance: exact binomial tests at 3-6 sigma thresholds;
  detects truncation that chi-square's bucket aggregation misses
- Sign/half-Gaussian factorization: (a) chi-square on |z| vs folded
  PDT, (b) per-|z| sign balance binomial test, (c) joint (sign,|z|)
  chi-square. Tests the z=(2b-1)*z0+b recombination step.
- Moment CIs: 95% confidence intervals on mean, stdev, skewness,
  kurtosis with asymptotic standard errors
- Discrete Anderson-Darling: Choulakian-Lockhart-Stephens tail-
  weighted EDF statistic, MC-calibrated (null depends on mu,sigma)
- Higher criticism: max standardized CDF deviation, near-optimal
  against sparse alternatives (single wrong table entry), MC-calibrated
- MC calibration helper: mc_calibrate() draws B replicates from the
  exact PDT, enabling correct p-values for any test statistic

Integration:
- UnivariateSamples.run_extended_battery() runs all new tests
- is_valid_extended = is_valid AND all extended tests pass
- to_dict() includes extended results when available
- run_baseline.py uses extended battery for scoring

Test vector update:
- Tail truncation changed from 6-sigma (undetectable at n=10000,
  mass ~e^{-18}) to 3-sigma (detectable, ~30 expected samples)

Baseline results:
- Bad detection: 71.4% -> 85.7% (tail truncation 0/6 -> 6/6)
- Good false alarms: 0/6 (0%) -- unchanged
- Remaining blind spot: Markov correlation (6/6 MISSED, Phase 4)

Test suite: 116 passed, 6 skipped (Markov), 0 failed
@jameshoweee

Copy link
Copy Markdown
Owner Author

consolidating into a single PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant