math::changepoint(3tcl)

πŸ“¦
version 2.0 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ math::changepoint ✨

okay bestie, so this is the math::changepoint page from the Tcl Math Library β€” yes the 3tcl one β€” and it's genuinely one of my faves because it's literally about catching the exact moment your data decides to switch up on you πŸ’…


NAME πŸŽ€

math::changepoint β€” change point detection methods. that's it, that's the whole vibe. finding where the plot twist happens in your numbers πŸ‘‘


SYNOPSIS 🌸

first you gotta require the whole squad:

package require Tcl 8.6 9

package require TclOO

package require math::statistics

package require math::changepoint ?0.2?

and then the actual commands, look:

::math::changepoint::cusum-detect data ?args?

::math::changepoint::cusum-online ?args?

$cusumObj examine value

$cusumObj reset

::math::changepoint::binary-segmentation data ?args?

DESCRIPTION πŸ¦‹

so the math::changepoint package implements a bunch of well-known methods for figuring out whether a series of data contains a shift in the mean or not. heads up though β€” these methods only tell you if a shift in the mean is probably happening. because data is stochastic (aka chaotic and dramatic by nature), false positives are absolutely possible, so don't come for me if your algorithm gaslights you a little πŸ™ˆ

The CUSUM method ships in two flavours: an "offline" version and an "online" version, so you can use it either on a complete data series or for detecting changes in data that arrives one by one, drip by drip, like your fave posting stories πŸ“

The implementation is mostly based on these websites, no cap:

Basically: you accumulate the deviation of the data from a given target value, and when the total deviation gets too large, a change point gets reported. periodt.

A second method, binary segmentation, is only implemented as an "offline" method, because it needs to examine the data series as a whole. it's giving "i need to see the full picture before i judge" energy πŸ’…

In the variant contained here, the following ideas have been used:

  • The segments in which the data series may be separated should not be too short, otherwise the ultimate result could be segments of only one data point long. so a minimum length is used. ✨
  • To make the segmentation worthwhile there should be a minimum gain in reducing the cost function (the sum of the squared deviations from the mean for each segment).

This may not be in agreement with the descriptions of the method found in various publications, but it is simple to understand and intuitive. and honestly? we love that for it. πŸ’–

One publication that provides more information on the method in general is "Selective review of offline change point detection methods" by Truong et al. β€” https://arxiv.org/abs/1801.00718


PROCEDURES 🌈

The package defines the following public procedures:

  • ::math::changepoint::cusum-detect data ?args? β€” Examine a given data series and return the location of the first change (if any). literally just "where did it all go wrong" but for numbers 😭
    • double data β€” Series of data to be examined
    • list args β€” Optional list of key-value pairs:
      • -target value β€” The target (or mean) for the time series
      • -tolerance value β€” The tolerated standard deviation
      • -kfactor value β€” The factor by which to multiply the standard deviation (defaults to 0.5, typically between 0.5 and 1.0)
      • -hfactor value β€” The factor determining the limits betweem which the "cusum" statistic is accepted (typicaly 3.0-5.0, default 4.0)
  • ::math::changepoint::cusum-online ?args? β€” Class to examine data passed in against expected properties. At least the keywords -target and -tolerance must be given. mandatory, bestie, don't skip them ⭐
    • list args β€” List of key-value pairs:
      • -target value β€” The target (or mean) for the time series
      • -tolerance value β€” The tolerated standard deviation
      • -kfactor value β€” The factor by which to multiply the standard deviation (defaults to 0.5, typically between 0.5 and 1.0)
      • -hfactor value β€” The factor determining the limits betweem which the "cusum" statistic is accepted (typicaly 3.0-5.0, default 4.0)
  • $cusumObj examine value β€” Pass a value to the cusum-online object and examine it. If, with this new value, the cumulative sum remains within the bounds, zero (0) is returned, otherwise one (1) is returned. so it's basically a vibe check that answers in binary πŸ‘€
    • double value β€” The new value
  • $cusumObj reset β€” Reset the cumulative sum, so that the examination can start afresh. the "we don't talk about what happened before" button 🫢
  • ::math::changepoint::binary-segmentation data ?args? β€” Apply the binary segmentation method recursively to find change points. Returns a list of indices of potential change points. it's giving detective energy πŸ”
    • list data β€” Data to be examined
    • list args β€” Optional key-value pairs:
      • -minlength number β€” Minimum number of points in each segment (default: 5)
      • -threshold value β€” Factor applied to the standard deviation functioning as a threshold for accepting the change in cost function as an improvement (default: 1.0)

KEYWORDS πŸ’œ

control, statistics


CATEGORY 🧚

Mathematics


Copyright (c) 2020 by Arjen Markus


and that's the whole page, bestie β€” every flag, every default, every link, all of it, no cap πŸ’–

okay so fun lil sign-off: this came out of tcllib, version 0.2, and it's the math::changepoint(3tcl) page. slay, go detect some change points, you've got this πŸ‘‘βœ¨πŸ¦‹

πŸ“¦ where this page comes from