Preprint — work in progress. The manuscript in
paper/is an unpublished draft prepared for submission to the Journal of Machine Learning Research. It has not yet been peer-reviewed or reviewed by my advisor, and its methods, results and wording may change. Please cite it as a preprint.
Manuscript (PDF) · Project page · Portfolio
Exact tests, detectable differences and sample-size design for evaluations of generative models based on the 2-Wasserstein distance.
A generative model is usually judged by the W₂ distance between a generated
sample and a sample of real data. That number is a measurement: it is biased
upward by the resolution floor (the distance between two independent
samples of the same law), and it fluctuates. certgen answers, from the real
data alone and before any model is trained, the questions that precede the
reading of such a measurement:
- Is a generator distinguishable from the data? An exact pooled permutation test, and the smallest shift it detects at a stated level and power.
- Which differences between two generators can an evaluation resolve, and how many samples does it need? A paired design whose minimum detectable difference falls as n^(-1/2) whatever the dimension, sized from a pilot at one size. The precision does not depend on the dimension; the quantity the comparison resolves can, and it is stated with the size.
- What does a distance mean? The floor is the bias, and for generators
that rescale or shift the data law it is exactly λ times the squared floor:
the plug-in distance rewards under-dispersed generators.
certgenreports a debiased squared distance, skill against reference generators, an upper confidence bound for W₂ that needs no model of the bias (asymptotic, or finite-sample for laws on a set of known diameter) and a two-sided interval. Off that family the debiased distance estimates a target that can move with n; the report gives the relative floor and the scale ratio, which agree on the family, andcorrected_distance_profilemeasures the drift. - Is the sample copied from the data? An exact rank test of distances to the closest training rows, with the near-duplicate ratio and the scale ratio that say what a flag can and cannot mean.
- What can a certificate prove at N observations? A bracket of the statistical term of latent-generative certificates by the floor at size N.
The methods, their operating characteristics, a pre-specified study on
public tabular benchmarks and a validation on trained tabular generators are
described in the accompanying manuscript, How Many Samples Does a Generative
Evaluation Need? Resolution Floors, Exact Tests and the Design of Wasserstein
Comparisons (paper/main.pdf).
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e . # the library: numpy and scipy only
pip install -e ".[dev,figures,experiments]" # tests, figures, all experimentsimport certgen as cg
# Before any model is trained: what can an evaluation with 500 rows per side resolve?
m = cg.null_moments(X_real, n=500) # squared floor and same-law spread
print(m.summary())
print("smallest detectable shift:", cg.minimum_detectable_shift(m))
# Comparing two generators: a pilot of two independent-columns samples.
t1 = cg.t1_sampler(X_real)
pilot = cg.paired_pilot(X_real, t1, t1, n=500, n_rep=10)
print("minimum detectable difference at n = 2000:", cg.mdd_at(pilot, 2000))
print("rows per side for a difference of 0.05:", cg.required_n_for_difference(pilot, 0.05))
print(cg.tail_diagnostic(X_real)) # the rule needs fourth moments
# Where the level of the bias matters: the floor law and its specification test.
law = cg.fit_floor_law(X_real)
print(law.summary())
# After training: the report of one generated sample.
report = cg.evaluate(X_real, X_generated, n_per_side=500)
print(report.summary()) # permutation p-values, debiased distance, skill, interval, copying
# Off the scalar-affine family the debiased distance can move with n: check it.
prof = cg.corrected_distance_profile(X_real, X_generated)
print(prof.summary()) # debiased distance at n/4 and n, drift and its standard errorThe same functions are available on the command line:
certgen design real.csv --n 2000 --delta 0.05 # floor, detectability, sizing
certgen test real.csv generated.csv # exact same-law permutation test
certgen compare real.csv a.csv b.csv --n 1000 # paired comparison of two generators
certgen evaluate real.csv generated.csv # the full report
certgen limit 4096 --dhat 12.3 # reference-table limit for certificatesThe floor law C n^(-1/d_eff) plans the level of the bias and is inverted
only where its specification test does not reject a single exponent;
FloorLaw.required_n_range otherwise shows how far the half-grid
prescriptions disagree. The size of a comparison comes from the variance
rule, which does not need the floor law.
| folder | contents |
|---|---|
certgen/ |
the library |
experiments/ |
one script per measurement reported in the manuscript; see experiments/README.md |
results/ |
the measured artifacts, one JSON file per experiment |
paper/ |
the manuscript (main.tex, references.bib, figures/, main.pdf) |
formal/ |
Lean 4 proofs of every proposition, corollary and lemma of the manuscript, indexed by statement number in formal/bridge/BridgePaper.lean; see formal/README.md |
tools/ |
builds of the manuscript's numbers, figures and PDF, the Lean build, the bibliography verification and the reproduction run |
tests/ |
the test suite |
docs/ |
reproducing the results, maintaining the project and the bibliographic verification |
python -m pytest # library, manuscript, Lean records, repository
python tools/reproduce.py # re-run every offline experiment and compareThe test suite checks the library's behaviour; that every number in the
manuscript is computed from an artifact and every numeric literal in it is
accounted for; that every reference is verified, in two bibliographic
indexes or by hand against its source;
that every figure is drawn from the current artifacts; and that the recorded
Lean builds certify the current proofs. tools/reproduce.py re-executes the
experiments in a copy of the project and compares every regenerated artifact
with the stored one. See docs/reproducing.md.
The framework uses W₂ for its design theory: the minimum detectable shift, the sample size of a comparison and the exact bias on the scalar-affine family follow in closed form from the floors, and the upward bias of its plug-in estimator is what the floor measures. In power, among the statistics the manuscript compares, its permutation test is far more powerful against changes of dependence than the energy distance, the MMD with a single bandwidth and sliced W₂, but the aggregated kernel test MMDAgg was at least as powerful on every alternative tested. It ranks no generators. The copying test protects the validity of a fidelity statement and is not a privacy guarantee. Training variance, which a design from real data cannot see, is measured in the manuscript's study of trained generators but not predicted.
The latent-generative certificates discussed are those of Dao et al. (2023),
Lee et al. (2025) and Mbacke et al. (2023); the rate of the floor is that of
Weed and Bach (2019). CHANGELOG.md describes the current
release.