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

Universal Hypothesis Testing with Kernels: Asymptotically Optimal Tests for Goodness of Fit

Shengyu Zhu, Biao Chen, Pengfei Yang, Zhitang Chen

Abstract

We characterize the asymptotic performance of nonparametric goodness of fit testing. The exponential decay rate of the type-II error probability is used as the asymptotic performance metric, and a test is said to be universally optimal if it achieves the maximum possible decay rate for all alternative distributions. We show that kernel-based tests, specifically those based on Maximum Mean Discrepancy (MMD) and Kernel Stein Discrepancy (KSD), can achieve this universal optimality under mild conditions.

Introduction

Goodness-of-fit (GoF) testing is a fundamental problem in statistics: given a set of data points $x^n$, does it follow a hypothesized distribution $P$? While well-understood for simple, low-dimensional cases, GoF testing becomes computationally and theoretically challenging for high-dimensional data or complex models where the probability density is only known up to a normalization constant.

A key theoretical question in information theory is whether a nonparametric test can be asymptotically optimal. An optimal test is defined as one where the probability of a Type-II error (false negative) vanishes at the fastest possible exponential rate—the Kullback-Leibler Divergence (KLD) between the null and alternative distributions—while the Type-I error (false positive) remains bounded. While this optimality has been established for finite sample spaces, this work extends these results to general, continuous spaces like $\mathbb{R}^d$ using kernel methods.

Methodology

The research focuses on two prominent classes of kernel-based tests:

  1. Maximum Mean Discrepancy (MMD): This approach measures the distance between the mean embeddings of two distributions in a Reproducing Kernel Hilbert Space (RKHS). The study evaluates both "simple" tests (comparing data to a known model) and "two-sample" tests (comparing two distinct datasets).
  2. Kernel Stein Discrepancy (KSD): This variation is particularly useful for complex models because it only requires the "score function" (the gradient of the log-density) of the model $P$. This bypasses the need for sampling from $P$ or calculating intractable integrals.

The core of the theoretical proof relies on Sanov’s Theorem from large deviation theory. Rather than analyzing the distribution of the test statistics directly, the authors use Sanov’s Theorem to examine the "acceptance region" of the tests. They further introduce an Extended Sanov’s Theorem to address the two-sample case where both sample sizes grow concurrently.

Key Theoretical Insights

The paper identifies several critical conditions for achieving universal optimality:

  • Weak Metrizability: For a kernel test to be optimal, the kernel must "metrize" weak convergence. This ensures that if the MMD or KSD approaches zero, the underlying distributions are indeed converging in a statistically significant manner.
  • Universal Optimality of MMD: MMD-based tests achieve the maximum possible error decay rate (the KLD) for any alternative distribution $Q$, provided the kernel is bounded, continuous, and characteristic.
  • KSD Trade-offs: While KSD offers computational advantages by avoiding sampling, it requires stricter assumptions on the kernel and the density function to achieve the same level of optimality.
  • Two-Sample Optimality: Quadratic-time MMD tests are shown to be optimal for general two-sample problems, regardless of the relative scaling of the two sample sizes.

Results and Performance

The primary result is that both MMD and KSD-based tests can attain the theoretical "speed limit" for statistical testing. Specifically, the probability of a Type-II error scales as $e^{-n \cdot D(P||Q)}$, where $n$ is the sample size and $D(P||Q)$ is the KLD.

  • MMD Optimality: Attains the optimal exponential decay rate under a constant Type-I error constraint on $\mathbb{R}^d$.
  • KSD Optimality: Achieves the same maximum decay rate, albeit under a "relaxed" asymptotic Type-I error constraint.

While the paper is primarily theoretical, the authors validated these findings in the finite sample regime (detailed in Appendix F), confirming that the asymptotic properties translate well to practical settings involving Gaussian and multivariate models.

Limitations and Future Directions

Despite the breakthrough in proving universal optimality, several challenges remain:

  • Kernel Selection: The theory proves optimality for a wide class of kernels but does not specify which kernel (e.g., which bandwidth for a Gaussian kernel) is optimal for small sample sizes, where sub-exponential terms dominate.
  • Non-i.i.d. Data: The current proofs assume independent and identically distributed (i.i.d.) data. Extending these results to dependent data, such as time series, is a significant area for future research.
  • Computational Efficiency: While "linear-time" versions of these tests are faster, they currently lack the weak convergence properties required for this specific proof of universal optimality. Bridging the gap between computational speed and statistical optimality remains a key objective.

Summary updated

BibTeX
@inproceedings{zhu2019universal,
  author = {Shengyu Zhu and Biao Chen and Pengfei Yang and Zhitang Chen},
  title = {{Universal Hypothesis Testing with Kernels: Asymptotically Optimal Tests for Goodness of Fit}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2019},
  url = {https://openreview.net/forum?id=Pgst_nLZEUt},
}
Figure