Result 115, Theoretical computer science

Sampling and counting contingency tables with arbitrary margins

For nonnegative integer matrices with prescribed row and column sums, gives exact uniform sampling in expected polynomial bit time and almost-uniform sampling in worst-case polynomial bit time. The dimensions and binary-encoded margins are unrestricted. Also gives a fully polynomial randomized approximation scheme for counting such tables with arbitrary individual cell bounds, including structural zeros, with polynomial cost on every execution.

Lean formalization Algorithm or complexity result

The bigger picture

Why it matters

A contingency table records counts arranged in rows and columns. The reported results offer efficient ways to draw such tables fairly and estimate how many exist when their row and column totals are fixed.

What changes?

The unreviewed manuscripts report exact uniform sampling of nonnegative integer matrices with prescribed row and column sums. It terminates almost surely in expected polynomial bit time; almost-uniform sampling has worst-case polynomial bit time. Both dimensions and binary-encoded margins are unrestricted, without positivity, balance or sparsity assumptions. They also report a fully polynomial randomized approximation scheme for counting tables with arbitrary individual cell bounds, including cells forced to zero. All counting data are binary-encoded, and every execution has polynomial bit cost.

What does that help mathematicians do?

For a researcher studying matrices with fixed totals, exact sampling means no feasible table is favored over another. The counting scheme estimates how many tables survive additional cell restrictions, within a requested relative error with high probability, at cost polynomial in input size and inverse error tolerance. These are distinct guarantees: the cell-bounded counting claim does not itself supply an exact sampler for cell-bounded tables.

Are there practical applications?

The immediate value is foundational: these claims provide general algorithmic tools for exploring count data with fixed totals and forbidden cells. Sampling could support statistical comparisons between observed tables and alternatives sharing their totals. The sources establish claimed complexity guarantees, not evidence of practical speed on large datasets.

This section was generated by GPT-6 Astra Medium. This explanation is based on the result summary and manuscript abstracts below. This context is separate from OpenAI's source text.

2 manuscripts

Exact Uniform Sampling of Contingency Tables with Arbitrary Margins

September 24, 2026 31 pages

We give an exact uniform sampler for nonnegative integer contingency tables with arbitrary prescribed margins. It terminates almost surely and has expected bit complexity polynomial in both dimensions and the binary length of the margins. No positivity, balance, sparsity, or fixed-dimension assumption is required.

Cite (BibTeX)
@misc{OAI:Exact-Uniform-Sampling-of-Contingency-Tables-with-Arbitrary-Margins-September-24-2026,
  author = {{OpenAI}},
  title = {{Exact Uniform Sampling of Contingency Tables with Arbitrary Margins}},
  howpublished = {OpenAI Math Release preprint
                  \href{https://github.com/openai/math/blob/main/preprints/Exact-Uniform-Sampling-of-Contingency-Tables-with-Arbitrary-Margins-September-24-2026/main.pdf}{OAI:Exact-Uniform-Sampling-of-Contingency-Tables-with-Arbitrary-Margins-September-24-2026}},
  year = {2026}
}

An FPRAS for Cell-Bounded Contingency Tables

September 24, 2026 47 pages

We give a fully polynomial randomized approximation scheme for counting nonnegative integer matrices with prescribed row sums, column sums, and individual entry bounds. Both dimensions vary, all numerical data are encoded in binary, and zero bounds are allowed. The algorithm uses only unbiased random bits and has a polynomial bound on its bit operations on every execution.

Cite (BibTeX)
@misc{OAI:An-FPRAS-for-Cell-Bounded-Contingency-Tables-September-24-2026,
  author = {{OpenAI}},
  title = {{An FPRAS for Cell-Bounded Contingency Tables}},
  howpublished = {OpenAI Math Release preprint
                  \href{https://github.com/openai/math/blob/main/preprints/An-FPRAS-for-Cell-Bounded-Contingency-Tables-September-24-2026/main.pdf}{OAI:An-FPRAS-for-Cell-Bounded-Contingency-Tables-September-24-2026}},
  year = {2026}
}

Lean formalization

OpenAI's note on what the formalization covers, from lean/docs/115.md.

Sampling and counting contingency tables with arbitrary margins

The following describes the scope of the Lean formalization related to the following accompanying paper(s):

Scope

The formalization gives an exact uniform sampler for nonnegative integer contingency tables with arbitrary prescribed row and column sums having equal totals. It terminates almost surely, every halted output is feasible, and each table has exactly the uniform limiting probability. Expected bit complexity is polynomial in the dimensions and the binary length of the margins.

It also gives a sampler with a fixed polynomial time bound on every execution whose total-variation error is at most 2−k2^{-k} for requested precision k≥1k\ge1. The same Comparator file includes the companion approximation scheme for counting tables with individual cell bounds.

The formalization gives a fully polynomial randomized approximation scheme for counting nonnegative integer matrices with prescribed row sums, column sums, and individual entry bounds. Both dimensions may vary, the margins and bounds are binary encoded, and zero entry bounds are allowed. For rational 0<ε,δ<10<\varepsilon,\delta<1, the algorithm returns a nonnegative estimate with relative error at most ε\varepsilon with probability at least 1−δ1-\delta, and returns zero on every execution when no table exists.

The running time is polynomial in the encoded input size, ε−1\varepsilon^{-1}, and log⁡(δ−1)\log(\delta^{-1}) on every random tape. The same Comparator file also contains the companion sampling results for tables without cell bounds.

Comparator links

Result Comparator statement
Exact and bounded-time sampling of contingency tables ContingencyTables.lean
Randomized approximate counting of cell-bounded contingency tables ContingencyTables.lean

Data from github.com/openai/math at commit adc7f12, committed October 6, 2026 at 21:58 UTC, last checked for changes about 8 hours ago. Titles, subjects, summaries, abstracts and Lean notes are OpenAI's; page counts are read from the PDFs. The map, related results, search, kinds of results and the named-problem index are Emergent Mind's, built with text embeddings and an LLM, and may contain errors.

An Emergent Mind Labs project. Emergent Mind is not affiliated with OpenAI. None of these results has been peer reviewed. Cite the manuscripts themselves, using the BibTeX on each result's page.