Overcoming the Quadratic Complexity Bottleneck in Kernel Testing

44 concepts33 papers1 proposal

Nonparametric statistical tests—such as those evaluating whether two samples come from the same distribution, whether two variables are independent, or whether a dataset fits a given model—are foundational tools in machine learning. Frameworks like Maximum Mean Discrepancy (MMD), the Hilbert-Schmidt Independence Criterion (HSIC), and Kernel Stein Discrepancy (KSD) are celebrated because they are universal: they can detect any arbitrary, non-linear discrepancy between distributions without making restrictive assumptions about the data's underlying shape.

However, this universality comes at a steep price. To compute an exact MMD or KSD, one must evaluate a kernel function over all pairs of data points, resulting in a quadratic computational complexity ($O(n^2)$). As Michael Jordan argues in On statistics, computation and scalability, modern data analysis requires treating computational constraints as first-class citizens alongside statistical goals. When datasets scale into millions of samples, an $O(n^2)$ algorithm becomes completely intractable.

To solve this, a major research direction has emerged focused on navigating the computation-statistics tradeoff: designing algorithms that break the quadratic bottleneck while preserving the maximum possible statistical sensitivity.


The Core Tradeoff: Power vs. Time

The most straightforward way to escape quadratic complexity is to use linear-time approximations ($O(n)$). For instance, instead of comparing every sample to every other sample, a naive linear test might split the data into isolated pairs and average the results.

But this introduces a severe penalty. As shown by Arthur Gretton et al. in Optimal kernel choice for large-scale two-sample tests and Qinyi Zhang et al. in Large-scale kernel methods for independence testing, throwing away pairwise comparisons drastically increases the variance of the test statistic. This variance explosion directly reduces statistical power—the probability that the test correctly identifies a true difference between distributions.

In Advances in Nonparametric Hypothesis Testing, Aaditya Ramdas quantifies this cost: dropping from quadratic to linear time requires a massive increase in sample size to maintain the same sensitivity. In low signal-to-noise environments, a standard linear-time test can completely fail to detect subtle differences, sacrificing the "universal optimality" that makes kernel methods attractive in the first place (Shengyu Zhu et al. in Universal Hypothesis Testing with Kernels: Asymptotically Optimal Tests for Goodness of Fit).

The Streaming Paradox

However, there is a counter-intuitive twist when dealing with data streams or infinite data pools. In these regimes, your primary constraint is time, not data.

As Arthur Gretton et al. and Aaditya Ramdas et al. in Fast Two-Sample Testing with Analytic Representations of Probability Measures point out, a linear-time test can process vastly more data points than a quadratic test within the same time budget. Because the availability of larger datasets compensates for the lower precision of the algorithm, the total statistical power over a fixed time window can actually be higher for a fast linear test than for an exact quadratic test restricted to a small subset of the data.


Bridging the Gap: Sub-Quadratic and Linear Solutions

To get the best of both worlds—the high power of quadratic estimators and the scalability of linear runtimes—researchers have developed several clever paradigms.

1. Block Averaging and Incomplete U-Statistics

Instead of choosing strictly between $O(n^2)$ and $O(n)$, we can operate in an intermediate regime. Wojciech Zaremba et al. introduced the B-test (B-test: A Non-parametric, Low Variance Kernel Two-sample Test), which breaks data into blocks of size $B$, computes the quadratic statistic within each block, and averages the results. This yields a flexible framework where adjusting the block size allows practitioners to smoothly trade computation time for lower variance.

Expanding on this, Antonin Schrab et al. in Efficient Aggregated Kernel Tests using Incomplete $U$-statistics demonstrate that to maintain theoretical consistency (ensuring the test can eventually detect any discrepancy as data grows), the number of evaluated pairs must grow slightly faster than strictly linear. Incomplete U-statistics provide the exact mathematical knob needed to achieve this optimal balance.

2. Learned Witness Points

Another approach avoids comparing all data points by representing the distributions analytically and evaluating them at a small set of optimized "test locations" or "witness points."

For example, Wittawat Jitkrittum et al. developed the Finite Set Stein Discrepancy (FSSD) in A Linear-Time Kernel Goodness-of-Fit Test. Instead of an all-to-all comparison, FSSD evaluates the model's fit at a few specific locations in the data space. By explicitly "learning" these locations to maximize the test's power, the authors achieve a linear-time test that remains highly sensitive to model discrepancies.

3. Coreset Compression

Rather than modifying the test statistic to fit the data, why not compress the data to fit the test?

In Compress Then Test: Powerful Kernel Testing in Near-linear Time, Carles Domingo-Enrich et al. introduce the Compress Then Test (CTT) framework. CTT uses a method called "kernel thinning" to compress a massive dataset into a much smaller, high-fidelity "coreset" that perfectly preserves the distributional properties. Running a traditional quadratic test on this tiny coreset yields near-linear overall runtime while matching the statistical power of the full exact test.


The Hidden Bottleneck: Eliminating Permutations

Even if an algorithm computes a test statistic in linear time, determining its statistical significance (the p-value) traditionally requires permutation testing. This involves randomly shuffling the data labels thousands of times and recomputing the statistic for each shuffle to construct a baseline null distribution. For $B$ permutations, this multiplies the computational cost back up to $O(B \cdot n)$ or $O(B \cdot n^2)$.

To eliminate this hidden bottleneck, recent work restructures the test statistics themselves so that their null distributions converge analytically to a simple, known shape—like a standard Gaussian bell curve—bypassing permutations entirely.

Traditional Kernel Test:
[Data] ──> Compute Statistic (O(n²)) ──> Permute Labels B Times (O(B × n²)) ──> P-value

Permutation-Free Test:
[Data] ──> Compute Restructured Statistic (O(n) or O(n²)) ──> Analytical Gaussian/Martingale Asymptotics ──> Instant P-value

In A permutation-free kernel two-sample test, Shubhanshu Shekhar et al. introduce the cross-MMD (xMMD) test. By utilizing sample-splitting and studentization, they force the statistic to follow a normal distribution under the null hypothesis, achieving a massive computational speedup while remaining minimax rate-optimal.

Similarly, Aaditya Ramdas et al. in A Martingale Kernel Two-Sample Test mathematically restructure the MMD into a martingale sequence (mMMD). Because martingale central limit theorems guarantee that the outputs will follow a standard normal distribution, the test provides instant, permutation-free p-values at the cost of only a minor, well-quantified drop in per-sample sensitivity.


Beyond Hypothesis Testing

This tension between computational tractability and statistical precision extends across the entire spectrum of modern data science:

  • Model Calibration: When evaluating whether a neural network's confidence matches its actual accuracy, high-fidelity calibration tests often scale quadratically. David Widmann et al. demonstrate a similar trade-off in Calibration tests in multi-class classification: A unifying framework and Calibration tests beyond classification, where linear-time calibration estimators require significantly more data than their quadratic counterparts to achieve the same certainty.
  • Unnormalized Models: In parameter estimation for complex probabilistic models where the normalizing constant (the partition function) is intractable, the Kernelized Stein Discrepancy (Jason D. Lee et al. in A Kernelized Stein Discrepancy for Goodness-of-fit Tests) allows practitioners to trade off the exactness of maximum likelihood estimation for computationally tractable, partition-function-free optimization.

Ultimately, the field is moving away from asking whether an algorithm is "exact" and toward asking how efficiently it converts a budget of computational time into statistical certainty.

Key Foundational Work

Optimal kernel choice for large-scale two-sample tests (2012) — contributed 2 concept elements to this direction.
B-test: A Non-parametric, Low Variance Kernel Two-sample Test (2013) — contributed 1 concept elements to this direction.
On statistics, computation and scalability (2013) — contributed 1 concept elements to this direction.
History & citationVersion 1 · 2026-10-04

Current · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_computation_statistics_tradeoff_ed1b62aa,
  title = {computation-statistics tradeoff},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/computation-statistics-tradeoff/rdr_ed1b62aa5ec240c49cd6863780911074},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-23},
}

This exact version (version 1, frozen text):

@misc{lacuna_computation_statistics_tradeoff_ed1b62aa_v1,
  title = {computation-statistics tradeoff},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/computation-statistics-tradeoff/rdr_ed1b62aa5ec240c49cd6863780911074/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-23},
}
About

These directions overlap with this one through shared papers.

See something wrong? Report a mistake