Sequential algorithms for testing identity and closeness of distributions

Omar Fawzi, Nicolas Flammarion, Aurélien Garivier, Aadil OufkirarXiv 2022

Abstract

Distribution testing—determining whether two sources of randomness are identical or distinct—is a fundamental task in statistics and machine learning. While traditional batch algorithms rely on fixed sample sizes determined a priori, this work explores sequential testing frameworks that observe data points incrementally. We demonstrate that sequential algorithms significantly outperform batch counterparts, achieving at least a four-fold reduction in sample complexity for small alphabets and providing adaptive speedups when distributions are significantly different.

Introduction

In distribution testing, researchers address two primary questions: Identity Testing (comparing an unknown distribution to a known reference) and Closeness Testing (comparing two unknown distributions). Traditionally, these tasks are performed using batch algorithms where a sample size $N$ is fixed in advance. This approach is often inefficient: if distributions are highly divergent, $N$ may be unnecessarily large; if they are nearly identical, $N$ may be insufficient to reach a confident conclusion.

This paper investigates the "frugality" of testing by transitioning to a sequential setting. In this paradigm, the algorithm evaluates the data after every sample and decides whether to stop and make a decision or continue sampling.

Methodology: Sequential Stopping Rules

The core of the proposed sequential approach lies in the development of robust stopping rules that maintain statistical validity across all possible time steps.

Time-Uniform Concentration

Unlike standard concentration inequalities (e.g., Hoeffding's) which hold for a fixed $N$, the authors utilize time-uniform concentration inequalities. These provide boundaries that are valid simultaneously for all stopping times $t$, effectively preventing "peeking" errors where an algorithm might stop prematurely due to random fluctuations.

Empirical TV Distance and Advanced Estimators

For small alphabet sizes ($n$), the algorithms monitor the Total Variation (TV) distance between empirical distributions. For larger alphabets, the authors adapt a sophisticated, unbiased test statistic ($Z$) from recent batch literature into a sequential form.

Sequential stopping boundaries for closeness testing ($n=2$).

Key Insights

The "Factor of 4" Advantage

A primary finding is that for small alphabets, sequential tests are at least four times more efficient than batch tests. This stems from the fact that a batch test must be sized to distinguish the null hypothesis ($D_1 = D_2$) from the alternative ($TV(D_1, D_2) > \epsilon$) simultaneously. A sequential test, however, can stop as soon as it gains sufficient evidence for either hypothesis.

Instance Adaptivity

Sequential algorithms are inherently "self-tuning." If the true distance $d$ between distributions is much larger than the required tolerance $\epsilon$, the algorithm detects this signal early and terminates. Batch algorithms lack this flexibility and must always consume the full sample budget $N$.

Results and Performance

The authors validated their theoretical bounds using Monte-Carlo simulations on synthetic discrete distributions.

Sample complexity comparison: Sequential vs. Batch lower bounds.

Sample Complexity Bounds

  • Small Alphabet ($n \ll \log(1/\delta)$): Sequential complexity is approximately $\frac{2 \log(1/\delta)}{\epsilon^2}$, whereas batch complexity is $\frac{8 \log(1/\delta)}{\epsilon^2}$.
  • General Alphabet: For closeness testing, the achieved complexity is: $$\tilde{O}\left( \max \left( \frac{n^{2/3} \log^{1/3}(1/\delta)}{d^{4/3}}, \frac{n^{1/2} \log^{1/2}(1/\delta)}{d^2}, \frac{\log(1/\delta)}{d^2} \right) \right)$$ where $d = \max(\epsilon, TV(D_1, D_2))$. This matches optimal batch bounds in the worst case but offers substantial gains when $d > \epsilon$.

Conclusion

This work establishes that sequentiality provides a constant-factor improvement in worst-case sample complexity and an order-of-magnitude improvement in many practical instances through adaptivity. Future research may extend these tight bounds to continuous distributions and explore the exact optimal constants for high-dimensional alphabets.

Summary updated

BibTeX
@misc{fawzi2022sequential,
  author = {Omar Fawzi and Nicolas Flammarion and Aurélien Garivier and Aadil Oufkir},
  title = {{Sequential algorithms for testing identity and closeness of distributions}},
  year = {2022},
  eprint = {2205.06069},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2205.06069},
}
Figure