← Latest papers
📊 statistics

focus and focus-cpt: Fast Online Changepoint Detection in R and Python

This paper introduces the `focus` and `focus-cpt` software packages for R and Python, which implement a family of exact, efficient algorithms for fast online changepoint detection across univariate and multivariate data streams by leveraging the geometric relationship between changepoint candidates and data structure to achieve logarithmic computational complexity without approximations.

Original authors: Gaetano Romano, Kes Ward, Yuntang Fan, Guillem Rigaill, Vincent Runge, Idris A. Eckley, Paul Fearnhead

Published 2026-07-23
📖 7 min read🧠 Deep dive

Original authors: Gaetano Romano, Kes Ward, Yuntang Fan, Guillem Rigaill, Vincent Runge, Idris A. Eckley, Paul Fearnhead

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

The Science of Spotting the Sudden Shift

Imagine you are watching a river. Most of the time, the water flows at a steady, predictable pace. But suddenly, a massive boulder drops in, or a hidden spring bursts open, and the current changes instantly. In the world of data science, this is called changepoint detection. It is the art of spotting the exact moment a process shifts from one behavior to another. Whether it's a heart monitor detecting an irregular heartbeat, a self-driving car noticing a pedestrian step off the curb, or a satellite sensing a burst of energy from deep space, finding these "boulders" in real-time is crucial.

However, there is a catch. As data streams in—millions of points per second—checking every single possibility for a change becomes a computational nightmare. It's like trying to find a specific grain of sand on a beach by measuring every single grain from the beginning of time every time a new one arrives. This is where online changepoint detection comes in: the challenge of finding the shift as it happens, without getting bogged down by the past. The paper you are about to read tackles this problem with a new, lightning-fast toolkit designed to catch these shifts in data streams, from simple temperature readings to complex, multi-dimensional signals, all while running fast enough for real-time decisions.

The Paper: A Speed Demon for Data Streams

The authors, a team of statisticians and computer scientists, have built a new software package called focus (and its Python twin, focus-cpt) that acts like a super-efficient detective for data streams. Their main finding is that they can calculate the "Generalised Likelihood Ratio" (GLR)—a fancy statistical test that asks, "Did something just change?"—with incredible speed and without cutting any corners.

Usually, checking for a change in a long list of numbers is slow. If you have nn data points, a naive method requires checking every possible starting point for a change, which takes a huge amount of computer power (specifically, O(n2)O(n^2) operations). The authors show that their new method, the focus algorithm, can do this exact same calculation but much faster. Instead of checking every single grain of sand, they use a clever geometric trick. They imagine the data points as a shape (a convex hull) and realize that only the "corners" of this shape matter. By ignoring the points inside the shape, they can prune the list of candidates down to a tiny, manageable size. This means the time it takes to check for a change grows very slowly (logarithmically) even as the data stream gets huge, making it perfect for real-time applications.

What the paper rules out:
The authors explicitly argue against using "approximations" to speed things up. Many other methods try to guess the answer or simplify the math to save time, but the authors insist that their method computes the GLR statistic exactly. They prove that you don't need to sacrifice accuracy for speed; you can have the precise answer without the slow processing time. They also rule out the idea that you must re-scan the entire history of data every time a new point arrives. Their method updates the list of "suspects" (candidate change points) incrementally, discarding those that are no longer relevant.

How sure are they?
The paper presents the method as a mathematical fact: the algorithm computes the exact statistic. However, the performance claims—specifically that it is fast enough for real-time use and works well in complex scenarios—are backed by simulations and demonstrations rather than a single universal proof for every possible real-world scenario. The authors show through various examples (simulated data and real-world case studies) that the method works as advertised. For instance, in their simulations, they show that for a 6-dimensional dataset, their "projection" approximation is significantly faster (taking about 0.166 seconds compared to 10.409 seconds for the full method) while producing results that are nearly identical (a mean relative difference of only 0.0037).

The Toolkit: How It Works in the Wild

The package is available for both R and Python, two popular languages for data science, and they share the same "brain" (a C++ backend), meaning they produce identical results. This makes it easy for scientists to switch between languages without changing their logic.

The toolkit is incredibly flexible. It can handle:

  • Simple data: Like a single stream of numbers (e.g., temperature).
  • Complex data: Multiple streams at once (e.g., a sensor on a satellite measuring heat, pressure, and radiation simultaneously).
  • Different types of data: It works with data that follows specific patterns (like the bell curve of a Gaussian distribution, or the count of events in a Poisson distribution) and even data where you don't know the pattern at all (non-parametric).

The authors demonstrate this flexibility with some cool real-world examples:

  1. NBA Basketball: They analyzed the "Plus-Minus" scores of the Cleveland Cavaliers. By using a custom detector that looked for changes in both the average score and the variability of the scores, they successfully pinpointed the moment the team's performance shifted, which coincided with the return of a famous player.
  2. Gamma-Ray Bursts: In the vastness of space, gamma-ray bursts are intense flashes of energy that last only a fraction of a second. The authors used their Python tool to detect these bursts in real-time from satellite data. Because the tool is so fast, it can identify the most significant moment of the burst as it happens, without needing to know beforehand how long the burst will last.
  3. Brain Spikes: They applied the tool to calcium imaging data, which measures the electrical activity of neurons. By using two detectors—one watching for spikes up and one for drops down—they could infer when neurons fired in real-time, a crucial step for "closed-loop" experiments where a computer reacts to brain activity instantly.

The "Magic" Behind the Speed

To understand why this is a big deal, imagine you are a security guard watching a video feed of a crowded street. A naive system would stop the video, rewind to the start, and check every single frame to see if a person changed their clothes. This would take forever. The focus algorithm is like a guard who only remembers the "corners" of the crowd's movement. If a person walks in a straight line, the guard ignores them. But the moment someone makes a sharp turn (a change), the guard instantly flags it.

The paper explains that this "corner" logic comes from the geometry of the data. By converting the data into a specific shape, the algorithm can mathematically prove that any point inside the shape is impossible to be the start of a change. This allows the computer to "prune" (cut out) thousands of unnecessary checks instantly.

For high-dimensional data (where you have many sensors), the authors introduce a smart shortcut. Instead of trying to find the corners of a complex, multi-dimensional shape (which is hard), they project the data onto smaller, overlapping 2D or 3D slices, find the corners there, and combine the results. They show in their simulations that this "projection" method is vastly faster than trying to calculate the full shape, yet it catches the changes just as well.

Why It Matters

The ultimate goal of this paper is to provide a common, fast, and accurate interface for scientists and engineers who need to detect changes in data streams right now. Whether it's monitoring the health of a power grid, spotting a cyberattack, or decoding a neuron's signal, the ability to process data exactly and efficiently in real-time is a game-changer. The authors have successfully bridged the gap between complex statistical theory and practical, usable software, proving that you don't have to choose between being fast and being right. You can have both.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →