NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

MMD Aggregated Two-Sample Test

Antonin Schrab, Ilmun Kim, Mélisande Albert, Béatrice Laurent, Benjamin Guedj, Arthur Gretton

TL;DR

This paper introduces MMDAgg, a novel, adaptive, and non-asymptotic two-sample kernel test that aggregates multiple Maximum Mean Discrepancy (MMD) tests. It achieves minimax optimality over Sobolev balls, even when the smoothness parameter is unknown, and maintains its performance across various kernel types and practical settings.

What Problem Does This Paper Address?

Comparing distributions is a fundamental problem in statistics and machine learning with applications across many fields. Traditional methods like the t-test are parametric and limited. Nonparametric tests, such as the Kolmogorov-Smirnov test, struggle with multivariate data. Kernel-based methods, like the Maximum Mean Discrepancy (MMD), offer a powerful nonparametric approach, but standard MMD tests often rely on asymptotic guarantees for their level control and require careful kernel selection (e.g., bandwidth tuning), which can be suboptimal or data-inefficient. This paper addresses the need for a nonparametric two-sample test that is:

  1. Non-asymptotic: Controls type I error even with small sample sizes.
  2. Adaptive: Works well without prior knowledge of distribution smoothness.
  3. Robust: Handles various kernel types and practical bandwidth choices.
  4. Powerful: Achieves high statistical power.

Methods

The core contribution is the MMDAgg test, which aggregates multiple single MMD tests.

  • Single MMD Test: The paper first proposes a single MMD test that uses either permutations or a wild bootstrap to determine the test threshold. This is a key innovation as it provides non-asymptotic level control, meaning the test reliably controls the Type I error rate even for small sample sizes, unlike previous asymptotic MMD tests.
  • MMDAgg (Aggregated Test): To address the practical challenge of unknown kernel smoothness parameters (which are crucial for optimal single MMD tests), MMDAgg aggregates multiple single MMD tests, each using a different bandwidth. This aggregation allows the test to be adaptive to the unknown smoothness parameter. The aggregation is done using a multiple testing correction procedure, ensuring the overall test maintains its non-asymptotic level.
  • Minimax Optimality: The authors prove that both the single MMD test (with a specific kernel choice) and the MMDAgg test achieve minimax optimality over Sobolev balls, meaning they are statistically optimal up to an iterated logarithmic factor. This optimality holds for a broad class of kernels.
  • Parameter-Free Implementation: A user-friendly, parameter-free implementation of MMDAgg is provided, utilizing an adaptive collection of bandwidths.

Datasets

The paper evaluates its method on:

  • Synthetic Data: Perturbed uniform distributions in 1D and 2D, designed to lie within Sobolev balls of varying smoothness.
  • Real-world Image Data: The MNIST dataset, down-sampled to 7x7 images, used for image shift detection experiments.

No new benchmarks were introduced; existing datasets were used to compare against state-of-the-art methods.

Key Insights and Ideas

  • Non-asymptotic Level Control is Crucial: The paper highlights that for many real-world applications (e.g., medical data, seismology), sample sizes are fixed and not necessarily large. Traditional asymptotic tests can fail to be well-calibrated in such scenarios. The proposed non-asymptotic level control is a significant practical advantage.
  • Adaptivity via Aggregation: The core idea of MMDAgg is to overcome the need for prior knowledge of distribution smoothness by aggregating tests with diverse bandwidths. This makes the test robust and adaptive without requiring data splitting for parameter selection.
  • Power Without Data Splitting: Unlike some adaptive methods that require splitting data for bandwidth selection (leading to reduced test power), MMDAgg uses all data for testing while achieving high power.
  • Kernel Choice Matters, but Aggregation Mitigates: While the choice of kernel and bandwidth can impact the power of a single MMD test, MMDAgg's aggregation strategy allows it to perform well across a wide range of bandwidths, effectively capturing differences at various lengthscales.
  • Theoretical Guarantees Translate to Practice: The paper demonstrates that the theoretical properties of MMDAgg (non-asymptotic level control and minimax optimality) translate into strong empirical performance, often outperforming other state-of-the-art methods.

Key Results

  • Non-asymptotic Level Control: The proposed single MMD test and MMDAgg test are proven to control the Type I error non-asymptotically.
  • Minimax Optimality: MMDAgg achieves minimax optimality over Sobolev balls, up to an iterated logarithmic term, for a broad class of kernels.
  • Empirical Performance:
    • On synthetic data with Sobolev smoothness, MMDAgg significantly outperforms other state-of-the-art MMD-based adaptive tests.
  • On real-world image data (MNIST), MMDAgg closely matches the power of tests using neural networks.
  • The performance of MMDAgg is robust to aggregating a large number of kernels (up to 12,000).
  • The adaptive, parameter-free collection of bandwidths for MMDAgg performs as well as or better than methods with carefully chosen, fixed bandwidth collections.
  • The test is effective even with unbalanced sample sizes, though balanced datasets are preferred for higher power.

Limitations and Future Work

  • Computational Cost: While MMDAgg is theoretically sound, the aggregation of many tests can still be computationally intensive, though the paper provides efficient implementation details.
  • Choice of Weights: While the paper proposes several weighting strategies (uniform, increasing, decreasing, centered) and a parameter-free adaptive collection, the optimal choice of weights can still depend on prior knowledge or specific data characteristics.
  • Future Work: The authors suggest exploring adaptive feature learning without data splitting, extending the framework to other testing scenarios (e.g., goodness-of-fit, independence), and developing more computationally efficient variants of the aggregated tests.

Summary updated

BibTeX
@article{schrab2023mmd,
  author = {Antonin Schrab and Ilmun Kim and Mélisande Albert and Béatrice Laurent and Benjamin Guedj and Arthur Gretton},
  title = {{MMD Aggregated Two-Sample Test}},
  journal = {J. Mach. Learn. Res.},
  year = {2023},
  url = {https://openreview.net/forum?id=Kd0zWdSfvH},
}
Figure