Maximum Mean Discrepancy on Exponential Windows for Online Change Detection

Florian Kalinke, Marco Heyden, Edouard Fouché, Klemens Böhm, Böhm, Klemens · DOI

Abstract

Detecting changes is of fundamental importance when analyzing data streams and has many applications, e.g., in predictive maintenance, fraud detection, or medicine. A principled approach to detect changes is to compare the distributions of observations within the stream to each other via hypothesis testing. Maximum mean discrepancy (MMD), a (semi-)metric on the space of probability distributions, provides powerful non-parametric two-sample tests on kernel-enriched domains. In particular, MMD is able to detect any disparity between distributions under mild conditions. However, classical MMD estimators suffer from a quadratic runtime complexity, which renders their direct use for change detection in data streams impractical. In this article, we propose a new change detection algorithm, called Maximum Mean Discrepancy on Exponential Windows (MMDEW), that combines the benefits of MMD with an efficient computation based on exponential windows. We prove that MMDEW enjoys polylogarithmic runtime and logarithmic memory complexity and show empirically that it outperforms the state of the art on benchmark data streams.

Introduction

In the analysis of data streams—such as sensor feeds, financial transactions, or network traffic—the underlying data distribution often shifts over time, a phenomenon known as concept drift. Detecting these shifts promptly is vital for maintaining the accuracy of machine learning models and identifying system anomalies.

The "gold standard" for comparing two distributions is the Maximum Mean Discrepancy (MMD). As a kernel-based method, MMD can detect any change in distribution (not just a change in the mean) without making rigid assumptions about the data's shape. However, traditional MMD estimators have a quadratic runtime complexity ($O(n^2)$), making them practically unusable for real-time, long-running streams where a naive approach would cost $O(t^3)$ per new observation. MMDEW addresses this bottleneck by combining MMD with an efficient exponential window data structure.

The MMDEW Algorithm

MMDEW achieves its efficiency through three primary innovations: exponential slicing, recursive kernel summaries, and logarithmic subsampling.

Exponential Slicing and Recursive Summaries

Instead of maintaining a single large sliding window, MMDEW uses a series of windows with sizes that increase exponentially ($2^0, 2^1, 2^2, \dots$). This allows for high-resolution detection in the recent past and more coarse-grained detection for older data.

The core technical breakthrough is the use of Recursive Kernel Summaries. The algorithm stores partial sums of kernel evaluations ($XX$ for internal window similarity and $XY$ for interactions between windows). Because these sums are additive, two windows can be merged or compared in $O(\log t)$ time without recomputing the entire MMD from scratch.

Recursive merging of exponential windows and kernel summaries in MMDEW.

Logarithmic Subsampling

To maintain a low memory footprint, each window of size $2^l$ only stores a uniform sample of $l+1$ observations. This ensures that as the stream grows, the memory footprint only grows logarithmically ($O(\log t)$), while the runtime per new observation is reduced to $O(\log^2 t)$.

Complexity and Theoretical Comparison

MMDEW is designed to operate on topological domains and provides analytical guarantees for its performance. Compared to existing methods like ADWINK or NEWMA, MMDEW offers a unique balance of theoretical rigor and computational efficiency.

Comparison of MMDEW with state-of-the-art change detection algorithms.

As shown in the table above, MMDEW achieves a polylogarithmic complexity of $O(\log^2 t)$, which is significantly more scalable than the quadratic or cubic complexities of traditional window-based detectors. Unlike many existing detectors that are ensembles of univariate methods, MMDEW looks at the joint distribution, allowing it to catch subtle multivariate shifts that others miss.

Key Results

The researchers evaluated MMDEW against several competitors using both synthetic streams and real-world classification benchmarks (e.g., CIFAR10, FashionMNIST, and Gas sensor data).

  • Accuracy: MMDEW achieved the highest $F_1$ score on 4 out of 5 real-world datasets.
  • Detection Delay: In scenarios requiring rapid detection, MMDEW was the top performer in half of the tested settings.
  • Efficiency: Empirical tests confirmed the $O(\log^2 t)$ runtime. While MMDEW has a higher fixed cost per observation than simple mean-based detectors, its cost remains nearly flat as the stream grows to millions of observations.
  • Robustness: It proved significantly more reliable than univariate approaches at detecting changes in covariance (correlation) structures.

Conclusion

MMDEW successfully bridges the gap between the theoretical power of MMD and the practical requirements of high-speed data stream processing. By leveraging exponential windows and recursive kernel summaries, it provides a scalable, non-parametric solution for detecting complex drifts in high-dimensional data. Future work may explore adaptive windowing strategies to further refine the trade-off between detection speed and accuracy.

Summary updated

BibTeX
@article{kalinke2025maximum,
  author = {Florian Kalinke and Marco Heyden and Edouard Fouché and Klemens Böhm and Böhm, Klemens},
  title = {{Maximum Mean Discrepancy on Exponential Windows for Online Change Detection}},
  journal = {Trans. Mach. Learn. Res.},
  year = {2025},
}
Figure