A Kernel Distribution Closeness Testing

Zhijian Zhou, Liuhua Peng, Xunye Tian, Feng Liu · OpenReview

Abstract

The distribution closeness testing (DCT) assesses whether the distance between a distribution pair is at least $\epsilon$-far. Existing DCT methods mainly measure discrepancies between a distribution pair defined on discrete one-dimensional spaces, limiting their applications to complex data like images. To extend DCT to more types of data, this paper introduces Norm-Adaptive Maximum Mean Discrepancy (NAMMD), a new measurement of distributional discrepancy that scales the standard MMD value using the Reproducing Kernel Hilbert Space (RKHS) norms of the distributions. Theoretically and experimentally, the authors demonstrate that NAMMD-based DCT has higher test power compared to MMD-based DCT, with bounded type-I error. Furthermore, NAMMD is shown to improve performance in standard two-sample testing scenarios.

Introduction

In machine learning, 'distribution shift' occurs when test data differs from training data. While traditional Two-Sample Testing (TST) determines if two distributions are identical ($P = Q$), real-world applications often require Distribution Closeness Testing (DCT). DCT asks if the distance between distributions is below a certain threshold ($d(P, Q) \le \epsilon$), allowing for minor, acceptable variations that don't compromise model performance.

Handling complex data like images in DCT typically involves Maximum Mean Discrepancy (MMD). However, a significant 'norm-blindness' issue exists: MMD can yield identical values for different pairs of distributions even when their statistical significance (p-values) differs significantly. This makes MMD an unreliable metric for setting universal closeness thresholds across varying data regimes.

Comparison of MMD and NAMMD across distributions with different RKHS norms. (a-b) show distributions with different norms. (c) illustrates MMD's 'norm-blindness' where the metric value remains constant despite changing p-values. (d) shows how NAMMD adapts its value to better reflect the statistical closeness.

Methodology: Norm-Adaptive MMD (NAMMD)

To address the limitations of MMD, the authors introduce NAMMD. This metric scales the standard MMD by the norms of the distributions in the feature space:

$$NAMMD(P, Q; \kappa) = \frac{\|\mu_P - \mu_Q\|^2_{\mathcal{H}_\kappa}}{4K - \|\mu_P\|^2_{\mathcal{H}_\kappa} - \|\mu_Q\|^2_{\mathcal{H}_\kappa}}$$

Key Technical Highlights

  • Norm-Adaptivity: By incorporating the RKHS norms (related to the concentration of the distributions), NAMMD becomes sensitive to the actual overlap and variance of the data. Effectively, it incorporates second-order information into a first-order distance measure.
  • Asymptotic Analysis: The authors derived the asymptotic Gaussian distribution for the NAMMD estimator. This is crucial for DCT because, unlike TST, permutation tests are not easily applicable when distributions are assumed to be different under the null hypothesis.
  • Testing Procedure: The paper provides a formal hypothesis testing procedure with a guaranteed bound on Type-I errors (false positives).

Experimental Results

The framework was evaluated across synthetic noise, tabular data (Higgs), and image datasets (MNIST, CIFAR-10, ImageNet).

  • Superior Power: NAMMD consistently outperformed state-of-the-art methods. For instance, on MNIST with a closeness parameter $\epsilon=0.1$, NAMMD achieved a test power of 0.931, compared to 0.715 for the TV-based baseline.
  • Better Sensitivity: NAMMD-based DCT showed higher rejection rates for distribution pairs exceeding the closeness threshold, proving it is a more sensitive detector of distributional shifts than standard MMD.
  • Practical Utility: In ImageNet experiments, NAMMD accurately reflected 'accuracy margins,' distinguishing between variants that caused minor versus major drops in model performance without requiring ground-truth labels for the test set.

Conclusion

NAMMD provides a more informative and powerful framework for Distribution Closeness Testing on complex data. By overcoming the norm-blindness of standard MMD, it offers a practical tool for monitoring distribution shifts in real-world ML pipelines. Beyond DCT, NAMMD also improves the power of standard two-sample tests, making it a versatile addition to the statistical machine learning toolkit.

Summary updated

BibTeX
@misc{zhou2025kernel,
  author = {Zhijian Zhou and Liuhua Peng and Xunye Tian and Feng Liu},
  title = {{A Kernel Distribution Closeness Testing}},
  year = {2025},
  eprint = {2507.12843},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.12843},
}
Figure