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

Bayesian Kernel Two-Sample Testing

Qinyi Zhang, Veit Wild, Sarah Filippi, Seth Flaxman, Dino SejdinovićJ. Comput. Graph. Stat 2020

TL;DR

This paper introduces a novel Bayesian framework for two-sample testing, allowing us to compare probability distributions in a principled and flexible way. By leveraging kernel mean embeddings and a Bayesian approach, the method automatically handles kernel parameter selection and can be applied to complex, high-dimensional data.

What Problem Does This Paper Address?

Comparing two probability distributions is a fundamental task in many scientific fields, from biology to finance. Traditional methods often struggle with complex, high-dimensional data or require careful manual tuning of parameters. While Bayesian approaches exist, they are often limited to simpler cases. This paper aims to bridge this gap by developing a Bayesian nonparametric two-sample test that is robust, flexible, and can automatically learn relevant parameters.

Methods

The core of this work lies in a Bayesian approach to comparing kernel mean embeddings (KMEs) of two distributions. KMEs represent probability distributions as points in a high-dimensional feature space, allowing for powerful comparisons using kernel methods. The authors model the difference between these KMEs using a Gaussian Process prior. This allows them to:

  • Bayesian Inference: Instead of a point estimate, they obtain a posterior distribution over the hypothesis (null vs. alternative) and the kernel parameters. This provides a more nuanced understanding of the evidence.
  • Automatic Kernel Parameter Selection: The Bayesian framework naturally integrates over the kernel hyperparameters (like lengthscale), removing the need for manual tuning and preventing suboptimal choices.
  • Bayes Factor: The method quantifies the evidence for the null hypothesis (distributions are the same) versus the alternative (distributions are different) using a Bayes factor.
  • Efficient Computation: The paper details efficient computational methods, particularly leveraging Kronecker product structures, to handle the high-dimensional nature of the problem.

Datasets

The paper evaluates the proposed method on a variety of synthetic datasets designed to mimic challenging scenarios, including:

  • 1D and 2D Gaussian distributions with varying means and variances.
  • 1D Laplace distributions.
  • Mixtures of Gaussian distributions.
  • High-dimensional Gaussian distributions.
  • Network heterogeneity data (from Städler and Mukherjee [2017, 2019]).
  • Six-membered monocyclic ring conformation data (from the Crystallography Open Database).

Key Insights and Ideas

  • Focusing on the Difference: Modeling the difference between kernel mean embeddings, rather than the embeddings themselves, simplifies the problem and avoids issues with non-negativity constraints of kernels.
  • Bayesian Integration is Key: Automatically inferring kernel parameters via Bayesian integration is crucial for robust performance, especially when a single "best" parameter is hard to find.
  • Flexibility of Kernels: The framework is kernel-agnostic, meaning it can be applied with various kernels suitable for different data types (e.g., Gaussian RBF for numerical data).
  • Beyond Independence: The method does not strictly require the independence of the two samples, which is a limitation of some frequentist approaches.

Key Results

  • The proposed Bayesian kernel two-sample test demonstrates strong performance across various synthetic and real-world datasets.
  • It successfully distinguishes between distributions that differ in mean, variance, or more complex structural ways.
  • The method shows robustness to increasing dimensionality, although larger sample sizes are needed for more challenging problems.
  • In real-world applications, such as comparing ring conformations, the method provides evidence that aligns with expert opinions.
  • The Bayesian approach naturally favors simpler hypotheses (null) when data is scarce, a desirable property.

Limitations and Future Work

  • Computational Cost: While efficient methods are proposed, very large sample sizes can still pose computational challenges. The authors suggest exploring random Fourier feature approximations for such scenarios.
  • Kernel Choice: While the framework is flexible, the choice of kernel still influences performance, and selecting an appropriate kernel for specific data types remains an area of interest.
  • Mixture Modeling: The authors suggest exploring connections to mixture modeling frameworks for Bayesian model selection as a potential avenue for future research.
  • Independence Testing: The developed framework can be extended to independence testing.

Summary updated

BibTeX
@article{zhang2020bayesian,
  author = {Qinyi Zhang and Veit Wild and Sarah Filippi and Seth Flaxman and Dino Sejdinović},
  title = {{Bayesian Kernel Two-Sample Testing}},
  journal = {J. Comput. Graph. Stat.},
  year = {2020},
}
Figure