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

Sequential Kernelized Stein Discrepancy

Diego Martinez-Taboada, Aaditya Ramdas

Abstract: We present a sequential version of the kernelized Stein discrepancy (KSD) goodness-of-fit test, enabling the continuous monitoring and adaptive stopping of tests for unnormalized densities. Unlike traditional batch tests that require a fixed sample size determined a priori, our framework allows practitioners to stop data collection at any time while maintaining rigorous control over the false discovery rate. By moving beyond the restrictive assumption of uniformly bounded Stein kernels and instead exploiting point-wise evaluations to define test martingales, we provide a mathematically robust method for testing complex models like Restricted Boltzmann Machines. We demonstrate the validity of the test and show that the wealth process grows exponentially under the alternative hypothesis.

Introduction

In classical statistical inference, hypothesis testing is typically conducted in a "batch" setting. A researcher must commit to a sample size $n$ before observing any data. This rigidity presents a significant dilemma: a sample size that is too small lacks the power to detect real effects, while a sample size that is too large wastes computational and experimental resources. Furthermore, "peeking" at results to decide whether to continue sampling—a common practice in many fields—invalidates standard p-values and inflates Type I error rates.

Presented at AISTATS 2025, "Sequential Kernelized Stein Discrepancy" by Diego Martinez-Taboada and Aaditya Ramdas introduces a framework for "anytime-valid" goodness-of-fit testing. This approach allows researchers to monitor data in real-time and stop as soon as sufficient evidence is gathered to reject a null hypothesis, without compromising statistical integrity.

The Challenge of Unnormalized Densities

Modern machine learning frequently utilizes probabilistic models where the density function is known only up to a normalizing constant. Examples include Bayesian posteriors, Ising models, and Restricted Boltzmann Machines (RBMs). For these models, calculating the normalizing constant is often computationally intractable, rendering standard goodness-of-fit tests unusable.

The Kernelized Stein Discrepancy (KSD) offers a solution by utilizing the "Stein operator," which depends only on the score function $\nabla \log p(x)$ rather than the density $p(x)$ itself. However, previous attempts to adapt KSD to sequential settings relied on the assumption that the Stein kernel is uniformly bounded. This is a significant limitation, as many of the most effective kernels, such as the Inverse Multi-Quadratic (IMQ) kernel, do not satisfy this property.

Methodology: Testing by Betting

The authors employ a "testing by betting" framework to achieve anytime-validity. In this paradigm, a test is viewed as a game where a bettor starts with $1 unit of wealth. At each time step $t$, the bettor observes a new data point $X_t$ and places a bet against the null hypothesis $H_0$. If $H_0$ is true, the wealth process is a test martingale, meaning its expected value remains $1$. If the wealth $W_t$ ever exceeds the threshold $1/\alpha$ (e.g., 20 for a 5% significance level), the null hypothesis is rejected.

Adaptive Normalization

To handle unbounded kernels, the authors introduce adaptive normalization. Instead of requiring a global bound on the kernel, they derive point-wise bounds $M_p(x)$. By normalizing the payoff at each step based on the specific data points encountered, they ensure the bettor's wealth never becomes negative—preserving the martingale property—while still allowing the test to utilize the full discriminative power of the kernel.

The paper evaluates two primary betting strategies:

  1. aGRAPA: An aggressive strategy designed to maximize the growth of wealth empirically.
  2. LBOW (Lower Bound On Wealth): A strategy providing theoretical guarantees on the exponential growth of wealth when the alternative hypothesis is true.

Empirical Evaluation

The SKSD framework was tested across several benchmarks representing different levels of complexity:

  • Gaussian Distributions: Establishing a baseline for standard normal testing.
  • Intractable "Tanh" Models: Testing non-Gaussian distributions where the normalizing constant is unknown.
  • Gaussian-Bernoulli Restricted Boltzmann Machines (RBMs): Evaluating complex graphical models where the score function is computable but the density is not.

Key Findings

  • Anytime Validity: The test remains valid regardless of the stopping rule. Researchers can stop because they reached a threshold, ran out of time, or observed a specific pattern, and the Type I error remains controlled.
  • Exponential Power: The authors prove that if the null hypothesis is false, the wealth will grow exponentially. This guarantees that the test will eventually reject the null given enough data.
  • Efficiency over ONS: Comparisons with the "Online Newton Step" (ONS) strategy used in prior literature showed that the aGRAPA strategy roughly doubled the log-wealth, providing significantly stronger evidence for the same amount of data.
  • Composite Hypotheses: The framework successfully extends to composite nulls (e.g., testing if data fits any member of a parametric family) by taking the infimum of wealth over the parameter space.

Conclusion and Future Work

Sequential Kernelized Stein Discrepancy provides a flexible, powerful tool for monitoring the fit of complex probabilistic models. While the current implementation faces a computational complexity of $O(t^2)$—typical for kernel methods—and requires the derivation of point-wise bounds for new distribution families, it represents a major step forward in making sequential testing practical for modern ML applications. Future research directions include extending the framework to categorical or functional data and optimizing the computational overhead for long-running tests.

Summary updated

BibTeX
@inproceedings{martineztaboada2025sequential,
  author = {Diego Martinez-Taboada and Aaditya Ramdas},
  title = {{Sequential Kernelized Stein Discrepancy}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2025},
  url = {https://openreview.net/forum?id=pW9UW8uDlR},
}
Figure