Skip to content

pelt

Source: src/pelt.rs

PELT (Pruned Exact Linear Time) changepoint detection in Rust.

Accelerates the O(n²) dynamic programming algorithm by moving inner loops to Rust and using precomputed cumulative sums for O(1) segment cost evaluation.

Internal Functions

These are internal Rust functions not directly callable from Python.

sum

Sum of data[start..end]

sum_sq

Sum of data[start..end]^2

mean

Mean of data[start..end]

cost_mean

Cost of segment [start, end) under a change-in-mean model. cost = sum((x - mean)^2) = sum(x^2) - n * mean^2

cost_var

Cost of segment [start, end) under a change-in-variance model. cost = n * log(var) where var = sample variance (ddof=1)

cost_meanvar

Cost of segment under change-in-mean-and-variance model.

pelt_single

Run PELT on a single group's data, returning changepoint indices.