---
title: Bayesian Online Changepoint Detection
url: https://www.emergentmind.com/topics/bayesian-online-changepoint-detection
type: topic
---

# Bayesian Online Changepoint Detection

Bayesian Online Changepoint Detection (BOCPD) is a recursive, exact Bayesian algorithm for detecting abrupt changes in the generative parameters of a data sequence in real time. It tracks the posterior distribution of the “run length”—the number of observations since the most recent changepoint—providing robust uncertainty quantification and well-calibrated online predictions. BOCPD is highly modular, allowing flexible insertion of different predictive likelihoods and priors, and can be extended to various domains including time-series with temporal dependence, outliers, high-dimensionality, and collective anomalies [0710.3742].

## 1. Problem Formulation and Core Quantities

BOCPD addresses the detection of changepoints—abrupt variations in the underlying data-generating process—within a streaming data context. At each time $t$ with observed data $x_{1:t}$, the objective is to recursively compute the posterior distribution over the run length:
\[
P(r_t = r \mid x_{1:t}), \quad r=0,1,2,\ldots
\]
where $r_t$ denotes the number of consecutive observations since the most recent changepoint; $r_t = 0$ implies a changepoint at $t$. When $P(r_t=0\mid x_{1:t})$ is high, an online changepoint is detected.

Key mechanisms:
- **Hazard function $H(\tau)$**: Specifies the probability that the next observation after a run of length $\tau-1$ will be a changepoint. It is related to the prior gap distribution $P_{\rm gap}$:
  \[
  H(\tau)=\frac{P_{\rm gap}(g=\tau)}{\sum_{g'=\tau}^{\infty}P_{\rm gap}(g')}
  \]
  For a geometric prior of mean $\lambda$, $H(\tau)=1/\lambda$.
- **Predictive distribution**:
  \[
  P(x_{t+1}\mid x_{1:t})=\sum_{r=0}^{t-1}P(x_{t+1}\mid r_t=r,x_{t-r+1:t})P(r_t=r\mid x_{1:t})
  \]

This construction enables probabilistic detection of changes and forward-looking predictions [0710.3742].

## 2. Message-Passing Recursion and Sufficient Statistics

The core inference procedure uses a recursive message-passing algorithm over run-length hypotheses:
- **Growth step** ($r_t = r_{t-1} + 1$): the run continues, no changepoint.
- **Changepoint step** ($r_t=0$): a changepoint occurs at $t$.

The joint probability is updated as follows:
\[
P(r_t, x_{1:t}) = \sum_{r_{t-1}} P(r_t|r_{t-1})\, P(x_t|r_{t-1}, x_{t-r_{t-1}:t-1})\, P(r_{t-1},x_{1:t-1})
\]

These steps reduce to two recursions:
- **Growth (no changepoint):**
  \[
  P(r_t=r_{t-1}+1, x_{1:t}) = P(r_{t-1}, x_{1:t-1})\,[1-H(r_{t-1}+1)]\,P(x_t|r_{t-1},x_{t-r_{t-1}:t-1})
  \]
- **Changepoint:**
  \[
  P(r_t=0, x_{1:t}) = \sum_{r'=0}^{t-1}P(r_{t-1}=r', x_{1:t-1}) H(r'+1)\,P(x_t|r_{t-1}=r', x_{t-r':t-1})
  \]

The run-length posterior is normalized:
\[
P(r_t=r\mid x_{1:t})=\frac{P(r_t=r,x_{1:t})}{\sum_{r=0}^t P(r_t=r,x_{1:t})}
\]

For exponential-family likelihoods with conjugate priors, only a fixed set of sufficient statistics needs to be maintained for each run-length hypothesis, enabling closed-form predictive updates and tractable per-step complexity [0710.3742].

## 3. Model Selection, Extensions, and Robustification

The modularity of BOCPD permits broad extensions:
- **Multimodel/changepoint detection:** BOCPD supports a model universe $\{M_k\}$, updating the joint run-length and model posterior recursively. Segment selection can be performed online for spatio-temporal VARs, Bayesian regression models, or mixtures [1805.05383].
- **Non-i.i.d. and temporal/structured models:** Autoregressive (AR) observation models [2407.16376], dynamic linear models, and Kalman filter–based sequential recursions for temporally correlated data [2310.18611] generalize BOCPD beyond i.i.d. environments.
- **Robustness to outliers:** Incorporating a mixture-outlier model, tracking candidates for the last outlier time and adjusting sufficient statistics, BOCPD can robustly detect changepoints without excessive FPs in the presence of anomalies [2112.12899].
- **Generalized Bayesian inference:** Diffusion score matching and general discrepancy-based posteriors provide theoretical robustness to misspecification and heavy-tailed contamination, maintaining tractability via conjugate-exponential families [2302.04759].

A summary of model classes and scalable update strategies is provided below:

| Extension             | Key Methodological Change                                                | Reference          |
|-----------------------|--------------------------------------------------------------------------|--------------------|
| Autoregression AR(q)  | Regime-wise AR(q), time-varying var/corr, score-driven updates           | [2407.16376]       |
| Kalman/State-Space    | Segment-wise DLM, closed Kalman updates, stitched for efficiency         | [2310.18611]       |
| Model Selection, VAR  | Run-length × Model recursion, VAR with spatial constraints               | [1805.05383]       |
| Outlier Robustification| Joint outlier/run tracking, sufficient-statistic exclusion               | [2112.12899]       |
| Generalized Bayes     | Discrepancy-based posterior, score matching, robustness guarantees       | [2302.04759]       |

## 4. Computational Complexity and Practical Implementations

BOCPD’s per-time-step complexity is $O(t)$ due to the need to propagate all run-length hypotheses. In practical implementations, two strategies ensure scalability:
- **Run-length support pruning**: Discard hypotheses for which the posterior falls below a threshold (e.g., $10^{-6}$), limiting the number of active run-lengths. Amortized complexity becomes $O(\mathbb{E}[r_t])$ under geometric hazards [0710.3742].
- **Windowing/truncation**: For long series, limit the maximum run considered ("windowing") to a manageable value (e.g., 100 observations), folding any tail mass to the maximum bin [2207.06409].

In high-dimensional or nonconjugate models, particle filters [2509.13293] or sequential variational methods [1901.07987] are integrated for parameter uncertainty representation and scalability, with resampling or optimal run-length selection for complexity control.

## 5. Empirical Performance and Applications

BOCPD and its extensions have been applied in domains including finance, biometrics, robotics, longitudinal health [2310.18611], environmental monitoring, and more. Empirical findings include:
- Fast, accurate detection of true changepoints (e.g., Gaussian mean shifts with near-unity posterior mass at $r=0$ immediately after change).
- In temporally correlated settings (e.g., state-space or AR models), Kalman filter recursions and autoregressive BOCPD improve mean-squared error and regime covering relative to i.i.d. models [2310.18611], [2407.16376].
- Joint online regression and change detection enables real-time monitoring for Earth observation (deforestation flagging with sub-day latency) [2112.12899].
- Robust and scalable generalizations (e.g., score-matching GB posteriors) suppress false alarms from outliers ("flash crashes") and enable order-of-magnitude computational gains over previous robust Bayesian methods [2302.04759].

## 6. Limitations, Assumptions, and Outlook

BOCPD assumes that the data-generating mechanism can be segmented into regimes, each (typically) exchangeable or Markovian, and that parameter dependence between regimes is either negligible or tractable. Exact inference is efficient in exponential-family + conjugate contexts, but models requiring nonconjugate likelihoods, unknown segment duration models, or collective anomaly interaction require approximation (e.g., variational, particle, or gradient-based schemes) [2509.13293], [2508.06385].

Limitations include:
- Inability to accommodate long-range autocorrelation natively unless extended with AR, DLM, or Gaussian process likelihoods.
- For collective anomalies interleaved with true change-points, naive BOCPD may misidentify or merge the two events. Extensions with anomaly-tracking or reversion priors are required [2508.06385].
- In streaming scenarios with high-frequency, high-dimensional signals, careful support pruning and model simplification are required to ensure real-time operation [2310.18611].

Research directions include embedding BOCPD within complex model selection, handling semi-Markov and nonstationary processes, and integrating active learning or resource constraints for edge applications [2103.14224].

---

**References**:  
- Adams & MacKay, "Bayesian Online Changepoint Detection" [0710.3742]  
- "Sequential Kalman filter for fast online changepoint detection" [2310.18611]  
- "Bayesian Autoregressive Online Change-Point Detection with Time-Varying Parameters" [2407.16376]  
- "Monitoring Deforestation Using Multivariate Bayesian Online Changepoint Detection with Outliers" [2112.12899]  
- "Robust and Scalable Bayesian Online Changepoint Detection" [2302.04759]  
- "Inferring Soil Drydown Behaviour with Adaptive Bayesian Online Changepoint Analysis" [2509.13293]  
- "Bayesian online collective anomaly and change point detection in fine-grained time series" [2508.06385]  
- "Active multi-fidelity Bayesian online changepoint detection" [2103.14224]  
- "Spatio-temporal Bayesian On-line Changepoint Detection with Model Selection" [1805.05383]  
- "Stein Variational Online Changepoint Detection with Applications to Hawkes Processes and Neural Networks" [1901.07987]

Source: https://www.emergentmind.com/topics/bayesian-online-changepoint-detection