Two-Sample Testing via Path-based Inference

Eshant English, Wei-Cheng Lai, Yanfeng Yang, Kenji Fukumizu, Taiji Suzuki, Christoph LippertarXiv 2026

TL;DR

This paper transforms deep generative models from synthesis tools into powerful statistical engines for two-sample testing. By routing datasets through a shared Gaussian bottleneck using stochastic interpolants, the authors prove that distributional differences manifest as path asymmetries, creating a new class of tests that outperform traditional baselines by up to 33 percentage points.

What Problem Does This Paper Address?

Two-sample testing is a fundamental statistical task: given two finite datasets, did they come from the same underlying distribution? While this sounds simple, it becomes incredibly difficult with high-dimensional, structured data like images or medical scans.

Traditional methods often fall short. Kernel-based methods like Maximum Mean Discrepancy (MMD) rely heavily on choosing the "right" kernel, which is non-trivial for complex data. Classifier-based tests (C2ST) can be powerful but often require large amounts of data to train effectively and can be unstable. The authors identify a gap: deep generative models (like diffusion models) learn the intricate structure of data distributions, yet we rarely use those learned dynamics for formal statistical inference.

Methods

The authors leverage the stochastic interpolant framework, which unifies diffusion models and flow matching. Their core innovation is the Gaussian-bottleneck interpolant.

Instead of trying to map distribution A directly to distribution B, they map both to a shared, neutral "pivot"—a standard Gaussian distribution. This creates a path with two halves. The researchers proved a critical theoretical result: if the two datasets come from the same distribution (the null hypothesis), the generative paths to the bottleneck will be perfectly reflection-symmetric.

The Gaussian-bottleneck construction. Under the null hypothesis (left), the paths are symmetric. Under the alternative (right), the asymmetry provides the signal for the test.

To turn this into a test, they:

  1. Train: Fit two separate neural networks (denoisers or velocity fields) on training splits of each dataset.
  2. Witness: Evaluate the "regression risk" (how well the model denoises) on a held-out test split.
  3. Aggregate: Sum these discrepancies along the entire generative path. They introduce a "Jeffreys weighting" that mathematically links this path integral to the Jeffreys divergence (a symmetrized version of KL divergence).
  4. Calibrate: Use permutation testing to ensure the test remains valid even if the neural networks aren't perfectly trained.

Datasets

The authors evaluated their "Path-Based Inference" (PBI) method on four distinct benchmarks:

  • HDGM: A 10-dimensional synthetic Gaussian mixture designed to test localized covariance shifts.
  • MNIST: The classic handwritten digits dataset, used here for class-contamination tests (e.g., testing a set of "3s" against a set that is 90% "3s" and 10% "8s").
  • OrganAMNIST: A medical imaging dataset consisting of 64x64 grayscale CT slices of lungs.
  • Fashion-MNIST: Grayscale images of apparel (e.g., Sneakers vs. Ankle Boots).

Key Insights and Ideas

  • The Path is the Point: Most generative model evaluations look only at the final samples. This paper argues that the entire trajectory of how a sample evolves from noise to data is a rich statistical object that contains more information than the endpoints alone.
  • Symmetry as a Statistical Signal: The "aha moment" is the proof that the null hypothesis is equivalent to reflection symmetry about the bottleneck. This turns a complex density estimation problem into a simpler symmetry-checking problem.
  • Built-in Interpretability: Because the test statistic is built from observation-level scores, it’s easy to identify which specific samples are driving a rejection. This allows researchers to flag corrupted data points in a batch rather than just getting a "yes/no" answer.
  • Stability of Fields: The method relies on the fact that score and velocity fields are stable statistical objects. Even if two models produce slightly different images, the underlying fields they learn for the same distribution are remarkably consistent.

Key Results

The proposed PBI tests significantly outperformed established baselines like MMDAgg, AutoTST, and C2ST across all benchmarks.

  • Power Gains: On the HDGM benchmark, PBI improved power over the strongest baseline by 22.8 percentage points at moderate sample sizes.
  • Image Performance: On Fashion-MNIST, the PBI-Denoiser variant achieved near-perfect power (0.732) at sample sizes where the best baseline was stuck at 0.500—a 23.2 percentage point lead.
  • Efficiency: The tests remain valid in finite samples and show high "sample efficiency," meaning they require fewer data points to reach a confident conclusion than traditional deep-learning-based tests.

Limitations and Future Work

  • Sample Splitting: The current method requires splitting the data into training (to learn the fields) and testing (to evaluate the symmetry). In extremely low-data regimes, this split might be a disadvantage.
  • Model Architecture: The choice between using a "denoiser" representation versus a "velocity" representation matters. The paper found that velocity worked better for synthetic data, while denoisers were superior for complex images, but a universal "best" choice isn't yet clear.
  • Computational Cost: Training two generative models just to run a hypothesis test is more computationally expensive than a simple MMD check.
  • Future Directions: The authors suggest exploring the use of pre-trained models to skip the training phase, which could make these tests much faster and even more powerful.

Summary updated

BibTeX
@misc{english2026two,
  author = {Eshant English and Wei-Cheng Lai and Yanfeng Yang and Kenji Fukumizu and Taiji Suzuki and Christoph Lippert},
  title = {{Two-Sample Testing via Path-based Inference}},
  year = {2026},
  eprint = {2610.05684},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.05684},
}
Figure