Zero-Flow Two-Sample Tests

Yakun Wang, Leyang Wang, Song Liu, Taiji SuzukiarXiv 2026

TL;DR

The paper introduces the Zero-Flow Two-Sample Test (ZF2ST), a novel framework that leverages the vector fields of flow-based generative models to detect differences between high-dimensional distributions. By splitting data into independent training and evaluation sets and focusing on directional alignment rather than field magnitude, ZF2ST achieves high testing power for complex structural changes while strictly controlling false-positive rates.

What Problem Does This Paper Address?

Two-sample testing is a foundational problem in statistics and machine learning: given two sets of samples, can we confidently determine if they come from different underlying distributions? This task is crucial for detecting dataset shift, evaluating generative models, and comparing complex datasets.

In high dimensions, however, traditional nonparametric tests (like Maximum Mean Discrepancy or classifier-based tests) often suffer from a severe drop in statistical power, especially when the differences are highly localized or concentrated along specific directions. While flow-based generative models are incredibly good at capturing complex, high-dimensional data structures, adapting them directly for hypothesis testing is challenging. Directly estimating a flow field introduces finite-sample noise that biases the test statistic, making it difficult to calibrate the test properly under the null hypothesis (i.e., when the distributions are identical).

Methods

The authors overcome this calibration challenge by introducing the Zero-Flow Two-Sample Test (ZF2ST), which relies on three main pillars:

  1. The Zero-Flow Criterion: If you independently pair samples from two identical distributions, the average displacement vector conditioned on their midpoint must be exactly zero everywhere. If the distributions differ, a non-zero velocity field emerges, acting as a "witness" to the distributional mismatch.
  2. Scale-Invariant Dual Representation: Instead of measuring the squared magnitude of the estimated velocity field—which introduces positive noise bias—the authors derive a dual formulation. This shifts the focus to the directional alignment between a learned witness field and the true displacements.
  3. Sample Splitting: The data is split into a training set and an evaluation set. A neural network witness is trained on the first split to learn the directional pattern of misalignment. It is then frozen and evaluated on the independent test split. Because the witness is fixed during evaluation, the test statistic admits standard, well-calibrated Gaussian behavior under the null hypothesis.

The authors propose two specific objectives for learning the witness network:

  • ZF-Reg: Direct least-squares regression targeting the midpoint velocity.
  • ZF-SNR: An objective that directly maximizes a regularized empirical signal-to-noise ratio of the test statistic.

Additionally, they introduce Dynamic Pairing as a training-time augmentation technique, randomly reshuffling the sample pairings between the two datasets at the start of each epoch to expose the network to a more diverse set of cross-pairs.

Datasets

The framework was evaluated on three distinct benchmarks:

  • High-Dimensional Gaussian Mixtures (HDGM): Bimodal Gaussian mixtures where the dimension scales up to 20, designed to test performance against high-dimensional alternatives.
  • Blob Datasets (Blob-S / Blob-D): A $3 \times 3$ grid of Gaussian mixtures. Blob-S represents the null case (identical distributions), while Blob-D introduces highly localized, mode-dependent covariance changes.
  • MNIST Mixture: A rare-contamination benchmark where distribution $P$ consists purely of digit 6 images, and distribution $Q$ contains 90% digit 6 and 10% digit 9 images.

Key Insights and Ideas

  • Direction Over Magnitude: Squaring an empirical velocity field turns estimation noise into a false signal, breaking the null distribution. Evaluating the linear alignment of a fixed direction completely bypasses this pitfall.
  • Decoupling Power from Calibration: Sample splitting means the neural network can be as complex and overparameterized as needed to maximize power, without ever compromising the validity of the Type-I error (false positive) control.
  • The Power of Dynamic Pairing: Refreshing sample pairs across training epochs acts as a massive data augmentation step, drastically boosting the model's ability to generalize to unseen evaluation pairs without inflating false positives.

Key Results

  • High-Dimensional Robustness: On the HDGM benchmark, both ZF2ST variants (ZF-Reg and ZF-SNR) maintain near-perfect testing power as the dimension increases to 20, whereas traditional kernel and classifier baselines suffer severe power degradation.
  • Semantic Contamination: On the MNIST rare-contamination task, ZF-Reg achieved the highest testing power across all sample sizes, demonstrating that vector-valued witnesses excel at capturing coordinated high-dimensional displacement patterns (like turning a 6 into a 9).
  • Strict Error Control: Across all experiments, the empirical Type-I errors remained tightly calibrated around the nominal 5% significance level ($\alpha = 0.05$).
Figure 1: Results on the HDGM benchmark for α = 0.05 (black line). Left: average test power (a) and type-I error (b) as the number of samples per distribution n increases, with d = 10. Right: average test power (c) and type-I error (d) as the dimension d increases, with n = 3000. Shaded regions show one standard error across independent training trials.

Limitations and Future Work

  • Dilution from Random Pairing: When distributional differences are purely confined to subtle within-mode covariance changes (as seen in the Blob-D dataset), random cross-pairing can dilute the local structure, meaning ZF2ST requires more samples to match the performance of specialized kernel methods.
  • Future Directions: Promising avenues for future work include studying more regularized witness classes (such as Reproducing Kernel Hilbert Spaces), establishing formal convergence guarantees for witness learning, and extending ZF2ST to learned feature spaces rather than raw data space.

Summary updated

BibTeX
@misc{wang2026zero,
  author = {Yakun Wang and Leyang Wang and Song Liu and Taiji Suzuki},
  title = {{Zero-Flow Two-Sample Tests}},
  year = {2026},
  eprint = {2607.21542},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.21542},
}
Figure