Neural Wasserstein Two-Sample Tests

Xiaoyu Hu, Zhenhua LinarXiv 2026 · DOI · arXiv

Abstract

The two-sample homogeneity testing problem is fundamental in statistics and becomes particularly challenging in high dimensions, where classical tests can suffer substantial power loss. We develop a learning-assisted procedure based on the projection 1-Wasserstein distance, which we call the neural Wasserstein test. The method is motivated by the observation that there often exists a low-dimensional projection under which the two high-dimensional distributions differ. In practice, we learn the projection directions via manifold optimization and a witness function using deep neural networks. To adapt to unknown projection dimensions and sparsity levels, we aggregate a collection of candidate statistics through a max-type construction, avoiding explicit tuning while potentially improving power. We establish the validity and consistency of the proposed test and prove a Berry–Esseen type bound for the Gaussian approximation. In particular, under the null hypothesis, the aggregated statistic converges to the absolute maximum of a standard Gaussian vector, yielding an asymptotically pivotal (distribution-free) calibration that bypasses resampling. Simulation studies and a real-data example demonstrate the strong finite-sample performance of the proposed method.

Introduction

The two-sample homogeneity test asks a fundamental question: "Do these two sets of data come from the same probability distribution?" While this is straightforward in low dimensions, it becomes increasingly difficult in high-dimensional settings—a phenomenon often referred to as the "curse of dimensionality."

Standard statistical tools, such as Maximum Mean Discrepancy (MMD) or Energy Distance, often suffer a massive loss in statistical power as the number of dimensions ($d$) increases. While the Wasserstein distance is a powerful alternative due to its ability to capture the underlying geometry of data, its empirical estimation also degrades as $d$ grows. The Neural Wasserstein Test addresses this by assuming that even if the data is high-dimensional, the critical differences between distributions often lie within a much smaller, low-dimensional subspace.

The Neural Wasserstein Framework

The proposed method introduces a learning-assisted procedure based on the projection 1-Wasserstein distance. This approach is built upon three primary methodological pillars:

1. Two-Step Learning and Manifold Optimization

Instead of optimizing all parameters simultaneously, the method employs a decoupled strategy. First, it learns the optimal projection directions ($U$) on a Stiefel manifold, ensuring the directions remain orthonormal. Second, it trains a Deep Neural Network (DNN) with ReLU activations to serve as a "witness function" ($f$) on the projected data. To satisfy the Kantorovich-Rubinstein duality of the Wasserstein distance, this function is constrained to be 1-Lipschitz via spectral normalization.

2. Sample Splitting for Statistical Validity

To ensure the test remains statistically valid and to avoid overfitting the test statistic to the noise in the data, the authors utilize sample splitting. One half of the data is used to "train" the neural network and identify the most discriminative projections. The remaining half is used to calculate the actual test statistic. This decoupling allows for the derivation of a clear, theoretically sound null distribution.

3. Max-Type Aggregation and Pivotal Calibration

Selecting the correct projection dimension ($k$) or sparsity level is typically a manual and error-prone process. The Neural Wasserstein Test bypasses this by calculating statistics for a range of hyperparameters and taking the maximum. The authors prove that this aggregated statistic converges to the absolute maximum of a standard Gaussian vector. This makes the test asymptotically pivotal (distribution-free), meaning researchers can determine p-values without the need for computationally expensive permutations or bootstraps.

Experimental Results

Simulation Studies

The method was evaluated against four distinct scenarios (Models A-D) representing mean shifts, variance shifts, and complex distributional differences in non-Gaussian settings across dimensions $d = 60, 200, \text{ and } 500$.

  • Superior Power: The Neural Wasserstein Test consistently outperformed MMD, Deep-Kernel MMD (MMD-D), Energy Distance, and Kernel Fisher Discriminant Analysis (KFDA).
  • Dimensionality Resilience: While the power of MMD and Energy Distance decayed sharply as dimensions increased, the proposed method's performance remained remarkably stable, demonstrating its effectiveness in high-dimensional regimes.

Real-World Application: DNA Methylation

The test was applied to DNA methylation data from The Cancer Genome Atlas (TCGA), comparing 511 samples of Lower Grade Glioma (LGG) against 150 samples of Glioblastoma Multiforme (GBM) across 207 gene variables. The test successfully identified significant differences ($p < 0.001$) in methylation patterns, aligning with established medical literature regarding tumor progression and genomic divergence between these cancer types.

Conclusion and Future Directions

The Neural Wasserstein Test represents a significant step forward in high-dimensional inference by combining the geometric strengths of optimal transport with the representational power of deep learning. By providing an asymptotically pivotal calibration, it offers a practical, high-speed alternative to traditional resampling-based tests.

Future research may address the trade-offs inherent in sample splitting, which effectively halves the available data for the final test. Additionally, exploring how specific hierarchical structures in distribution differences might be exploited through specialized neural architectures remains a promising avenue for further improving the test's convergence rates and sensitivity.

Summary updated

Abstract

The two-sample homogeneity testing problem is fundamental in statistics and becomes particularly challenging in high dimensions, where classical tests can suffer substantial power loss. We develop a learning-assisted procedure based on the projection 1-Wasserstein distance, which we call the neural Wasserstein test. The method is motivated by the observation that there often exists a low-dimensional projection under which the two high-dimensional distributions differ. In practice, we learn the projection directions via manifold optimization and a witness function using deep neural networks. To adapt to unknown projection dimensions and sparsity levels, we aggregate a collection of candidate statistics through a max-type construction, avoiding explicit tuning while potentially improving power. We establish the validity and consistency of the proposed test and prove a Berry--Esseen type bound for the Gaussian approximation. In particular, under the null hypothesis, the aggregated statistic converges to the absolute maximum of a standard Gaussian vector, yielding an asymptotically pivotal (distribution-free) calibration that bypasses resampling. Simulation studies and a real-data example demonstrate the strong finite-sample performance of the proposed method.
BibTeX
@misc{hu2026neural,
  author = {Xiaoyu Hu and Zhenhua Lin},
  title = {{Neural Wasserstein Two-Sample Tests}},
  year = {2026},
  eprint = {2601.21732},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2601.21732},
}
Figure