Skip to content

Phase 4: sequence tests — Ljung-Box, runs, block homogeneity - #5

Open
jameshoweee wants to merge 1 commit into
jh/phase3-univariatefrom
jh/phase4-sequence
Open

Phase 4: sequence tests — Ljung-Box, runs, block homogeneity#5
jameshoweee wants to merge 1 commit into
jh/phase3-univariatefrom
jh/phase4-sequence

Conversation

@jameshoweee

Copy link
Copy Markdown
Owner

Adds 3 sequence-dependence tests to univariate_tests.py — these close the last blind spot where a sampler has perfect marginals but serial correlation (e.g. Markov-coupled output):

  • Ljung-Box: Q(h) portmanteau test for autocorrelation at lags 1..20
  • Wald-Wolfowitz runs test: above/below median run count
  • Block homogeneity: chi-square homogeneity across 10 stream blocks, catches mid-run drift

After this, all generated bad vectors (including markov-coupled ones) are detected. 0% false alarms on good vectors.

New tests added to univariate_tests.py:
- Ljung-Box (4.1): Q(h) = n(n+2) * sum r_k^2/(n-k) ~ chi2(h),
  tests serial autocorrelation up to lag 20. Catches Markov-
  coupled samplers with perfect marginals.
- Wald-Wolfowitz runs test (4.2): tests randomness of above/below-
  median sequence. ~20 lines, marginal power beyond Ljung-Box but
  catches non-linear dependence.
- Block homogeneity (4.3): chi-square homogeneity across 10 stream
  blocks. Catches mid-run drift or state corruption invisible to
  pooled distributional tests.

All three integrated into run_extended_battery().

Baseline results:
- Bad detection: 85.7% -> 100.0% (Markov 0/6 -> 6/6)
- Good false alarms: 0/6 (0%) — unchanged
- ZERO remaining blind spots across all 7 flaw types

Test suite: 122 passed, 0 skipped, 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