Skip to content

feat: add Symbolic Divergence online change-point detection algorithm#9

Open
gtmnnn wants to merge 13 commits into
PySATL:mainfrom
gtmnnn:gtmnnn/symbolic-divergence
Open

feat: add Symbolic Divergence online change-point detection algorithm#9
gtmnnn wants to merge 13 commits into
PySATL:mainfrom
gtmnnn:gtmnnn/symbolic-divergence

Conversation

@gtmnnn

@gtmnnn gtmnnn commented Jun 20, 2026

Copy link
Copy Markdown

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).

@Desiment Desiment self-requested a review June 20, 2026 17:11
Comment thread pysatl_cpd/algorithms/online/symbolic_divergence/divergences/base.py Outdated
Comment thread pysatl_cpd/algorithms/online/symbolic_divergence/divergences/base.py Outdated
Comment thread pysatl_cpd/algorithms/online/symbolic_divergence/divergences/kl_divergence.py Outdated
Comment thread pysatl_cpd/algorithms/online/symbolic_divergence/divergences/kl_divergence.py Outdated
Comment thread pysatl_cpd/algorithms/online/symbolic_divergence/symbolic_divergence.py Outdated
Comment thread pysatl_cpd/algorithms/online/symbolic_divergence/symbolic_divergence.py Outdated
@Desiment Desiment self-requested a review June 20, 2026 17:57
gtmnnn added 6 commits June 21, 2026 10:22
- 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)
@gtmnnn gtmnnn force-pushed the gtmnnn/symbolic-divergence branch from 0762114 to 5224454 Compare June 21, 2026 07:27
gtmnnn added 7 commits June 21, 2026 11:16
…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.
@Desiment Desiment self-requested a review June 23, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants