feat: add Symbolic Divergence online change-point detection algorithm#9
Open
gtmnnn wants to merge 13 commits into
Open
feat: add Symbolic Divergence online change-point detection algorithm#9gtmnnn wants to merge 13 commits into
gtmnnn wants to merge 13 commits into
Conversation
Desiment
reviewed
Jun 20, 2026
Desiment
requested changes
Jun 20, 2026
- make divergence stateless (drop reset from IDivergence and KLDivergence) - compute KL divergence in a numerically stable log-difference form, handle zero and very large counts - document that divergences accept raw frequencies or probabilities - add explicit gamma > 0 check in SlopeEncoder for a clearer error - drop redundant __repr__ override (already provided by the base class)
0762114 to
5224454
Compare
…SlopeKLSymbolicDivergence - turn SymbolicDivergence into an abstract base generic over ConfigurationT/StateT (mirrors GeneralizedCUSUM); make configuration/state abstract and expose read accessors for subclasses - add concrete SlopeKLSymbolicDivergence with a configuration that stores the slope/divergence parameters (delta, gamma, smoothing), so distinct detector instances hash differently and are identified correctly in benchmarking - update public exports in the three __init__.py files
Add a log-damped change-point statistic (scale * n / log(n+1) * D)
…reference WindowedSymbolicDivergence (generic base) and concrete WindowedSlopeKLSymbolicDivergence: empirical distribution over a fixed recent window vs a growing reference; default statistic is the raw divergence.
…ence growth and statistic reset
Desiment
approved these changes
Jun 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds SymbolicDivergence and WindowSymbolicDivergence, a generalized online change-point detection algorithm to pysatl_cpd.algorithms.online. It encodes a sliding window of observations into a symbol, monitors the divergence between the running empirical symbol distribution and a reference distribution fixed at the end of the learning period, and maps that divergence stream to a change-point statistic.
The algorithm is built from three interchangeable, pluggable components, making the Slope-encoding + Kullback-Leibler + 2nD combination a single special case of a broader family:
• Encoder (ISymbolEncoder): h: R^k -> S, window-to-symbol mapping. SlopeEncoder is the canonical k = 2 case.
• Divergence (IDivergence): compares the empirical symbol distribution to the reference. KLDivergence (with smoothing) is provided.
• Change-point statistic (IChangePointStatistic): turns the raw divergence stream (and symbol count n) into the emitted statistic. RawDivergenceStatistic (identity, default) and ScaledDivergenceStatistic (scale * n * D; scale = 2.0 reproduces 2nD).