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

Asymptotically Optimal One- and Two-Sample Testing With Kernels

Shengyu Zhu, Biao Chen, Zhitang Chen, Pengfei Yang

Introduction

In statistical hypothesis testing, the primary objective is to determine whether a given sample originates from a specific distribution (one-sample testing) or whether two distinct samples are drawn from the same underlying distribution (two-sample testing). While many modern tests are "consistent"—meaning they correctly identify the true hypothesis as the sample size approaches infinity—a more rigorous criterion for performance is the rate at which the probability of error vanishes.

This paper investigates the asymptotic optimality of kernel-based tests, specifically those utilizing Maximum Mean Discrepancy (MMD) and Kernel Stein Discrepancy (KSD). By leveraging Large Deviation Theory, the authors demonstrate that these kernel methods achieve the fastest possible exponential decay of Type-II error rates under a fixed Type-I error constraint, reaching the theoretical "speed limit" established by the Chernoff-Stein Lemma.

Theoretical Foundations: Sanov’s Theorem and Large Deviations

The study of error exponents is rooted in Large Deviation Theory. For simple hypotheses, the Chernoff-Stein Lemma identifies the Kullback-Leibler Divergence (KLD) as the optimal rate of decay for the Type-II error. However, extending this to the "universal" nonparametric setting—where no prior information about the distributions is available—is significantly more complex.

The authors utilize Sanov’s Theorem, a fundamental result that describes how empirical distributions deviate from their true means. A major theoretical contribution of this work is the derivation of an Extended Sanov’s Theorem. This extension accommodates two independent sample sequences ($x^n$ and $y^m$) that may grow at different rates, providing the necessary mathematical framework to characterize the error exponent for two-sample tests.

Kernel Metrics and Weak Metrizability

The paper focuses on two primary kernel-based statistics:

  1. Maximum Mean Discrepancy (MMD): Measures the distance between mean embeddings of distributions in a Reproducing Kernel Hilbert Space (RKHS).
  2. Kernel Stein Discrepancy (KSD): Utilizes Stein’s identity to perform goodness-of-fit testing without requiring the normalization constant of the target distribution.

A critical insight of the research is the role of weak metrizability. For a kernel test to be asymptotically optimal, the chosen kernel distance must metrize the weak topology of probability measures. This ensures that a small kernel distance between two distributions implies they are truly close in a probabilistic sense. If a distance fails to satisfy this property, the resulting test may not achieve universal optimality.

Key Results

One-Sample and Two-Sample Optimality

The authors prove that plug-in MMD and KSD tests are asymptotically optimal for one-sample testing. Specifically, they achieve a Type-II error exponent equal to the KLD between the null and alternative distributions ($D(P||Q)$).

For two-sample testing, the authors derive the exact error exponent for quadratic-time MMD tests: $$D^* = \inf_{R} [c D(R||P) + (1-c) D(R||Q)]$$ where $c$ represents the ratio of the sample sizes. They demonstrate that no other two-sample test can surpass this rate, establishing MMD as a gold-standard approach for homogeneity testing.

Efficiency and Applications

The research highlights that KSD-based tests achieve the same optimality as MMD while offering greater computational efficiency for one-sample testing. Because KSD does not require drawing samples from the target distribution or calculating complex integrals, it is particularly well-suited for high-dimensional goodness-of-fit tasks.

Furthermore, these results are applied to off-line change-point detection. The authors prove that an MMD-based "maximum partition" strategy is optimal for identifying a single change-point in a sequence of observations, even when the distribution following the change is unknown.

Discussion and Limitations

One of the most surprising findings is kernel independence in the asymptotic limit. While the choice of kernel and its hyperparameters (such as bandwidth) are vital for performance on finite datasets, the optimal error exponent itself is independent of the kernel, provided the kernel is characteristic, bounded, and continuous.

However, several challenges remain:

  • Finite Sample Regime: In practice, the choice of kernel remains critical. Asymptotic optimality does not guarantee superior performance on small or medium-sized datasets.
  • Sample Space Constraints: The current proofs assume the sample space is a Polish, locally compact Hausdorff space. Future work may explore relaxing the "locally compact" requirement.
  • Non-IID Data: The analysis assumes independent and identically distributed (i.i.d.) samples. Extending these results to dependent data, such as time series, is an open area of research.
  • Computational Complexity: The optimal tests discussed are quadratic-time ($O(m^2)$). While linear-time alternatives exist, they often sacrifice weak metrizability, and their asymptotic optimality remains unproven.

Conclusion

By bridging the gap between Large Deviation Theory and Kernel Methods, this paper provides a rigorous theoretical foundation for the use of MMD and KSD in statistical testing. The proof that these methods are asymptotically optimal solidifies their position as powerful, principled tools for nonparametric inference.

Summary updated

BibTeX
@misc{zhu2019asymptotically,
  author = {Shengyu Zhu and Biao Chen and Zhitang Chen and Pengfei Yang},
  title = {{Asymptotically Optimal One- and Two-Sample Testing With Kernels}},
  year = {2019},
  eprint = {1908.10037},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1908.10037},
}
Figure