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

Sequential Predictive Two-Sample and Independence Testing

Aleksandr Podkopaev, Aaditya Ramdas

Abstract

We present a framework for sequential two-sample and independence testing that leverages modern machine learning classifiers instead of traditional kernels. By framing the testing problem as a game where a gambler bets on a predictor's success, we develop "anytime-valid" tests that maintain a controlled false positive rate while allowing for early stopping. Our approach, "Testing by Betting," utilizes classification-based payoffs and adaptive betting fractions to handle complex, high-dimensional data. Empirical results on synthetic and real-world datasets, including facial images and MNIST digits, demonstrate that our method significantly outperforms state-of-the-art kernel-based sequential tests in terms of statistical power and sample efficiency.

Introduction

In statistical inference, two-sample testing determines if two datasets originate from the same distribution, while independence testing evaluates the relationship between variables. Traditional "batch" tests require a fixed sample size determined a priori. Deviating from this by "peeking" at results to stop early inflates the Type I error rate. Sequential testing addresses this by providing "anytime-valid" inference, allowing researchers to monitor data streams and terminate collection upon reaching significance.

However, existing sequential methods rely heavily on kernel methods, which face significant challenges in high-dimensional spaces. Selecting an appropriate kernel for complex data, such as images, is difficult, and poor choices lead to substantial power loss. This paper introduces a new framework that replaces hard-to-tune kernels with flexible machine learning classifiers, effectively bypassing the kernel selection bottleneck.

Methods: Testing by Betting

The core of our framework is the principle of "Testing by Betting." We conceptualize the test as a game where a gambler starts with an initial wealth of \$1. At each time step $t$, the gambler observes a new data point and wagers a portion of their wealth on whether it was drawn from distribution $P$ or $Q$.

Classification-based Payoffs

Instead of fixed kernels, we employ a sequentially updated classifier (e.g., a Convolutional Neural Network or Multi-Layer Perceptron). If the classifier distinguishes between the two groups better than chance, the gambler's wealth increases. The wealth process is a non-negative martingale under the null hypothesis, ensuring that the probability of the wealth ever exceeding $1/\alpha$ is bounded by $\alpha$ (e.g., 0.05).

Adaptive Betting and Derandomization

To optimize performance, we utilize an Online Newton Step (ONS) strategy to adaptively determine betting fractions based on the classifier's evolving accuracy. For independence testing, we introduce a derandomization technique to ensure stability and power by creating synthetic independent pairs and averaging payoffs. This "time-uniform control" guarantees validity regardless of the stopping time.

Results

We evaluated our methods against synthetic models and high-dimensional real-world datasets, including the Karolinska Directed Emotional Faces (KDEF) and MNIST.

Synthetic and Model Performance

Our tests demonstrate robust performance across various data structures. In synthetic scenarios, the classification-based approach adapts to the complexity of the task.

Performance of the proposed test on parametric and nonparametric synthetic models.

As shown in the figure above, the rejection rate reaches 1.0 more efficiently as the difference between distributions ($\delta$) increases, maintaining the $\alpha=0.05$ error cap even in nonparametric settings.

High-Dimensional Image Data

The advantages of our framework are most evident in high-dimensional tasks. In the KDEF experiment, we tested the ability to distinguish between different facial expressions.

Comparison of Seq-C-2ST and Kernel 2ST on the KDEF facial expression dataset.

As illustrated in the comparison above, our classification-based test (Seq-C-2ST) achieved perfect power significantly faster than the state-of-the-art kernel-based approach (Kernel 2ST). Similarly, on MNIST independence tasks, our proposed Seq-C-IT required approximately half the data of kernel-based alternatives to reach the same confidence level.

Discussion and Conclusion

Our framework demonstrates that predictors do not need to be perfect to be effective; they only need to be consistently better than random guessing. This "learnability" ensures that the test will eventually reject a false null hypothesis (power-one). Furthermore, the betting framework is inherently robust to distribution drift, as it only requires fairness at each individual step.

While powerful, the approach has limitations. Regression-based independence tests currently underperform compared to classification-based versions, and the computational cost of updating neural networks at each step is higher than simple kernel evaluations. Future research will focus on more efficient incremental learning updates and improving scaling factors for regression-based payoffs. In summary, by replacing kernels with classifiers, we provide a flexible and powerful tool for modern sequential statistical testing.

Summary updated

BibTeX
@inproceedings{podkopaev2023sequential,
  author = {Aleksandr Podkopaev and Aaditya Ramdas},
  title = {{Sequential Predictive Two-Sample and Independence Testing}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=bN1ZBSOV2f},
}
Figure