Skip to main content

Module bocpd

Module bocpd 

Source
Expand description

BOCPD — Bayesian Online Change-Point Detection.

Reference: Adams & MacKay, Bayesian Online Changepoint Detection, arXiv:0710.3742 (2007).

Core idea: at each time t maintain a posterior P(r_t | x_{1..t}) over the run length r_t (the number of samples since the last change-point). Updates factorise into

  P(r_t = r_{t-1}+1 | x_{1..t}) ∝ P(r_{t-1} | x_{1..t-1}) ·
                                  UPM(x_t | x_{1..t-1}, r_{t-1}) ·
                                  (1 − H(r_{t-1}+1))

  P(r_t = 0 | x_{1..t}) ∝ Σ P(r_{t-1} | x_{1..t-1}) ·
                             UPM(x_t | x_{1..t-1}, r_{t-1}) ·
                             H(r_{t-1}+1)

with a constant hazard H(r) = 1/λ (geometric run-length prior) and a Student-t UPM derived from a Normal-Gamma conjugate prior on (μ, σ²).

We report a change-point at time t when the MAP run length (argmax_r P(r_t | x_{1..t})) drops by more than one step from the previous time. This is the standard point-decision rule given in §2.1 of Adams & MacKay (and is what the cited Figure 3 plots): a MAP drop means the posterior has collapsed back toward r = 0, signalling a regime change. Under a constant hazard, a fixed P(r_t = 0) > τ rule is pinned near the hazard rate even on obvious shifts — the MAP rule avoids that degeneracy.

Structs§

Bocpd