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

A Kernel Method for the Two-Sample-Problem

Arthur Gretton, Karsten M. Borgwardt, Malte J. Rasch, Bernhard Schölkopf, Alexander J. Smola

Determining whether two sets of data come from the same underlying distribution is a foundational challenge in statistics known as the "two-sample problem." This paper introduces Maximum Mean Discrepancy (MMD), a powerful kernel-based framework designed to solve this problem efficiently. By mapping distributions into a high-dimensional feature space, the authors provide a computationally efficient test that works on complex, high-dimensional data and even structured objects like graphs.

The Two-Sample Problem

Given two sets of observations, $X$ and $Y$, did they originate from the same probability distribution ($p = q$)?

This question has massive implications across fields. In bioinformatics, researchers need to know if a treatment group’s gene expression significantly differs from a control group. In database management, engineers might need to match attributes (e.g., "Salary" vs. "Wage") across different schemas by comparing their underlying data distributions.

Classical tests like the Kolmogorov-Smirnov test work well for simple, one-dimensional numbers but break down when data becomes high-dimensional or non-vectorial (like strings or graphs). The authors sought a method "rich enough" to detect any subtle difference between distributions, yet "restrictive enough" to provide reliable results even with small sample sizes.

The Maximum Mean Discrepancy (MMD) Method

The core innovation of this paper is the Maximum Mean Discrepancy (MMD). The approach relies on several key concepts:

  1. Mean Embeddings as Proxies: Instead of comparing histograms or densities directly, the authors look for a "smooth" function that is large on points from distribution $p$ and small (negative) on points from distribution $q$. The MMD is the maximum possible difference between the mean values of such a function on the two samples.
  2. The Kernel Trick: By restricting this search to the unit ball of a Reproducing Kernel Hilbert Space (RKHS), the MMD elegantly simplifies into the distance between the "mean embeddings" of the two distributions in that space. A complex probability distribution is represented as a single point in a high-dimensional Hilbert space; comparing distributions becomes a simple matter of calculating the distance between two points.
  3. Universality: If a "universal" kernel (like the Gaussian or Laplace kernel) is used, the MMD is mathematically guaranteed to be zero if and only if the distributions are identical.
  4. Statistical Tests: The authors propose two ways to turn this distance into a formal statistical test:
  5. Uniform Convergence Bounds: A conservative test providing "finite sample guarantees." It rarely gives false positives but might miss subtle differences.
  6. Asymptotic Distribution: A more sensitive test based on the theory of U-statistics. It approximates the "null distribution" (what MMD looks like when $p=q$) using bootstrapping or moment-matching.

Crucially, the computational cost is $O(m^2)$, where $m$ is the number of samples, making it highly practical for many real-world datasets.

Key Results and Applications

Because MMD only requires a kernel function, it can be applied to any data type for which a kernel exists. The authors evaluated MMD across several diverse domains, including neuroscience (electrode recordings), bioinformatics (microarray data), and database attribute matching.

Superior Sensitivity on Complex Data

The asymptotic MMD test (denoted as MMD$^2_u$) consistently outperformed or matched classical alternatives like the multivariate t-test and the Friedman-Rafsky tests (Smir/Wolf).

Performance of MMD and baseline tests on neuroscience and bioinformatics datasets.

On high-dimensional datasets with very few samples—such as the "Health status" microarray data—MMD was significantly more effective at detecting differences than standard multivariate tests. The table above demonstrates how MMD$^2_u$ accurately rejects the null hypothesis (low percentage) when distributions are different, while maintaining high acceptance when they are the same.

Attribute Matching Across Schemas

One of the most compelling applications demonstrated is database attribute matching. By combining MMD with the Hungarian marriage algorithm, the authors tested the method's ability to match corresponding columns across different database schemas.

Attribute matching accuracy across diverse data types, including structured graph data.

Remarkably, MMD achieved 100% accuracy in matching attributes for several datasets, including FOREST, ENZYME, and PROTEINS. The inclusion of ENZYME and PROTEINS is particularly notable because these are represented as structured graphs, demonstrating MMD's unique ability to handle non-vector data where classical tests fail.

Limitations and Future Directions

While MMD represents a significant leap forward for the two-sample problem, the authors note a few limitations:

  • Kernel Selection: The performance of MMD heavily depends on the choice of kernel and its parameters (e.g., the width $\sigma$ of a Gaussian kernel). While the authors use a median distance heuristic, optimal kernel selection remains an open research question.
  • Computational Scaling: Although $O(m^2)$ is efficient compared to many non-parametric tests, it can still become a bottleneck for "Big Data" scenarios involving millions of samples.
  • Conservative Bounds: The uniform convergence test, while theoretically sound, is often too conservative for practical use compared to the asymptotic version.

Despite these challenges, MMD provides a highly flexible, mathematically rigorous foundation for comparing complex datasets across virtually any domain.

Summary updated

BibTeX
@inproceedings{gretton2006kernel,
  author = {Arthur Gretton and Karsten M. Borgwardt and Malte J. Rasch and Bernhard Schölkopf and Alexander J. Smola},
  title = {{A Kernel Method for the Two-Sample-Problem}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2006},
  url = {https://openreview.net/forum?id=bOSh3RIqH7n},
}
Figure