Exact conditional distributions and moments of chi-square-family statistics on two-way contingency tables (cell-separable dynamic programming): reproducibility package
Abstract
The exact-computation engine beneath a contingency-table methodology series built on the T_root statistic. Given a two-way contingency table, this code computes, WITHOUT enumerating tables, the exact conditional moments and the exact conditional distribution of any chi-square-family statistic (Pearson X^2, the power-divergence members, the variance-stabilized T_root/Anscombe root), conditioning on BOTH margins (the multivariate Fisher noncentral hypergeometric law), by a cell-separable dynamic program whose cost is the number of margin states rather than the number of tables. Includes: the moment engine (verified against brute-force enumeration to 8.9e-15) and its vectorized form (exact conditional moments of a 5x5 table at three per cell -- about 79 billion tables on the margin fibre -- in ~3 s); the distribution engine (verified to 1.1e-15) that returns the exact atomic tail where a three-moment chi-square fit misses it by up to 0.296; the one-complex-per-state conditional characteristic-function engine (verified to 2.7e-15) with COS cosine-series inversion; the constrained-alternative (non-null) moment derivation; the family-wise application (exact simultaneous critical values for interaction-cell residuals, computed by exact fibre enumeration); the figure generators; a formatted derivations appendix (Dwyer_Derivations_ExactDistributionEngine, DH1 to DH8, docx and pdf) that consolidates the mathematics; and a test suite that verifies the exactness claims against enumeration. Shipped as the installable package `condexact` (public API: conditional_moments, conditional_distribution, conditional_tail, cramer_v_interval). Every numerical result in the manuscript regenerates from this code and is checked against enumeration where feasible; data are simulated and enumerated only. MIT License for code; CC BY 4.0 for documents.
Publication details
- Journal / source
- Zenodo (CERN European Organization for Nuclear Research)
- Publication date
- 11 August 2026
- Language
- EN