A Hilbert Space Embedding of Distributions
Authors: Alex Smola, Arthur Gretton, Le Song, Bernhard Schölkopf
Published: 2007
Venue: International Conference on Algorithmic Learning Theory
Summary
This paper introduces kernel mean embeddings, representing probability distributions as elements in a Reproducing Kernel Hilbert Space. This powerful technique enables nonparametric statistical inference using kernel methods.
Key Contributions
1. Mean Embedding of Distributions
For a distribution on and kernel , the mean embedding is:
This is an element of the RKHS .
2. Reproducing Property for Expectations
For any function :
This allows computing expectations via inner products.
3. Characteristic Kernels
A kernel is characteristic if the embedding is injective:
Examples: Gaussian RBF, Matérn kernels.
4. Empirical Estimation
Given samples :
Mathematical Framework
Bochner Integral
The mean embedding is defined via Bochner integral:
exists when .
RKHS Distance Between Distributions
This is the Maximum Mean Discrepancy (MMD).
Covariance Operator
The covariance operator :
Enables covariance-based inference in RKHS.
Applications
1. Two-Sample Testing
Test using empirical MMD:
2. Independence Testing
Test independence of and using HSIC:
3. Conditional Embeddings
Conditional mean embedding:
Enables nonparametric conditional density estimation.
4. Kernel Bayes' Rule
Compute posterior embeddings from prior and likelihood embeddings:
Algorithm: MMD Two-Sample Test
import numpy as np
def compute_mmd(X, Y, kernel):
"""
Compute Maximum Mean Discrepancy between samples.
Parameters:
-----------
X : array of shape (n, d) - samples from P
Y : array of shape (m, d) - samples from Q
kernel : function - kernel function K(x, y)
Returns:
--------
mmd_squared : float - squared MMD statistic
"""
n, m = len(X), len(Y)
# Compute kernel matrices
K_XX = np.array([[kernel(x_i, x_j) for x_j in X] for x_i in X])
K_YY = np.array([[kernel(y_i, y_j) for y_j in Y] for y_i in Y])
K_XY = np.array([[kernel(x_i, y_j) for y_j in Y] for x_i in X])
# Unbiased estimator
mmd_squared = (
(K_XX.sum() - np.trace(K_XX)) / (n * (n - 1)) +
(K_YY.sum() - np.trace(K_YY)) / (m * (m - 1)) -
2 * K_XY.mean()
)
return mmd_squared
def mmd_permutation_test(X, Y, kernel, n_permutations=1000):
"""Permutation test for H0: P = Q."""
combined = np.vstack([X, Y])
n = len(X)
observed_mmd = compute_mmd(X, Y, kernel)
count = 0
for _ in range(n_permutations):
perm = np.random.permutation(len(combined))
X_perm = combined[perm[:n]]
Y_perm = combined[perm[n:]]
if compute_mmd(X_perm, Y_perm, kernel) >= observed_mmd:
count += 1
p_value = count / n_permutations
return p_value
Theoretical Results
Convergence Rate
The empirical embedding converges at parametric rate.
Test Power
For characteristic kernels, MMD test is consistent:
- Type I error controlled at level
- Power as for
Extensions
- Kernel Adaptive HSIC: Optimize kernel for independence testing
- Distributional Embeddings: Embed distributions of distributions
- Kernel Mean Matching: Domain adaptation
- Stein Operators: Combine with score functions
Impact
This paper has enabled:
- Nonparametric hypothesis testing
- Domain adaptation (covariate shift)
- Generative model evaluation (GAN metrics)
- Causal discovery
- Distributional regression
Citation
@inproceedings{smola2007hilbert,
title={A Hilbert space embedding for distributions},
author={Smola, Alex and Gretton, Arthur and Song, Le and Sch{\"o}lkopf, Bernhard},
booktitle={International Conference on Algorithmic Learning Theory},
pages={13--31},
year={2007}
}
Further Reading
- Gretton, A., et al. (2012). A kernel two-sample test
- Song, L., et al. (2009). Hilbert space embeddings of conditional distributions
- Muandet, K., et al. (2017). Kernel mean embedding of distributions: A review