{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Change-point study\n", "\n", "[Change point analysis](http://www.variation.com/cpa/tech/changepoint.html) or [change detection](https://en.wikipedia.org/wiki/Change_detection) deals with abrupt changes in statistical properties of time series. *bayesloop* includes two types of abrupt changes: an abrupt change in parameter values is modeled by the transition model `Changepoint`. In contrast to this change in value, the transition model itself may change at specific points in time, which we will refer to as *structural breaks*. These structural changes are implemented using the `SerialTransitionModel` class. The following two sections introduce the `ChangepointStudy` class and describe its usage to analyze both change-points and structural breaks in time series data." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-04-27T19:15:25.427112Z", "iopub.status.busy": "2026-04-27T19:15:25.426670Z", "iopub.status.idle": "2026-04-27T19:15:26.382728Z", "shell.execute_reply": "2026-04-27T19:15:26.382222Z" } }, "outputs": [], "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt # plotting\n", "plt.style.use('seaborn-v0_8-whitegrid') # plot styling\n", "\n", "import bayesloop as bl\n", "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Analyzing abrupt changes of parameter values\n", "\n", "The `ChangepointStudy` class represents an extension of the `HyperStudy` introduced above and provides an easy-to-use interface to conduct change-point studies. By calling the `fit` method, this type of study first analyzes the defined transition model and detects all instances of the `Changepoint` class. Instead of directly using all combinations of predefined change-points provided by the user, it then computes a list of all valid combinations of change-point times and fits them (basically preventing the double-counting of change-point times due to reversed order). With Bayesian evidence as an objective fitness measure, this type of study can be used to answer the general question of when changes have happened. Furthermore, we may compute a distribution of change-point times to assess the (un-)certainty of these points in time.\n", "\n", "