Skip to content

Port Otava's changepoint detection to Rust - #1535

Draft
epompeii wants to merge 1 commit into
u/ep/changepoint/slotfrom
u/ep/changepoint/port
Draft

epompeii wants to merge 1 commit into
u/ep/changepoint/slotfrom
u/ep/changepoint/port

Conversation

@epompeii

Copy link
Copy Markdown
Member

A new crate, plus/bencher_changepoint, ports the default changepoint detection of Apache Otava to Rust: the E-divisive statistic of Matteson and James proposes candidates, a pooled variance Student t-test decides significance, the series is scanned in overlapping windows, and a relaxed first pass finds weak candidates that a merge then prunes against the real p value and the minimum magnitude. It is a pure function with no database, I/O, or async: a series and Otava's 3 parameters (window length, p value threshold, minimum magnitude) in, every changepoint with its statistics out.

The port follows Otava's master at commit d4f62a1, which carries 2 fixes that no release has yet: the merge refreshes both neighbors of a removed changepoint, and the t-test uses sample standard deviations. The port moves to the first release that carries them.

It departs from Otava in one place: a series with a non-finite value is refused with an error.

Faithfulness

  • Otava's own tests that use no random numbers are ported as literal vectors, and Otava's slow reference for the statistic is ported as an oracle for the fast path.
  • 54 vector cases, generated by running Otava at d4f62a1 over its own series, the TigerBeetle series in its perf test, the real series in MongoDB's signal-processing-algorithms, and series chosen to pin each edge (odd windows, ties in the statistic and between intervals, the first pass at a p value of 1, a window of 2, and the order of each sum). Indices are asserted exactly, statistics to a relative 1e-9. The generator script sits beside the vectors.
  • The Student t CDF comes from statrs. A tie in exact arithmetic between 2 p values can break differently from scipy, mostly on integer series at a high p value threshold; the docs say so.

License

The ported files and their vectors are derived from Apache-2.0 work, so they carry Apache-2.0 headers that name Otava and the commit and state the changes, the crate is license = "Apache-2.0", and a new NOTICE carries Otava's notice. The Plus license applies only to what is not distributed under MIT or Apache-2.0.

Nothing calls the crate yet.

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

ProjectBencher
Branchu/ep/changepoint/port
Testbedintel-v1
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
microseconds (µs)
(Result Δ%)
Upper Boundary
microseconds (µs)
(Limit %)
Adapter::Json📈 view plot
🚷 view threshold
5.26 µs
(+1.19%)Baseline: 5.20 µs
5.48 µs
(96.07%)
Adapter::Magic (JSON)📈 view plot
🚷 view threshold
5.13 µs
(+2.01%)Baseline: 5.03 µs
5.29 µs
(96.96%)
Adapter::Magic (Rust)📈 view plot
🚷 view threshold
26.35 µs
(-1.82%)Baseline: 26.84 µs
28.65 µs
(91.97%)
Adapter::Rust📈 view plot
🚷 view threshold
4.52 µs
(+1.21%)Baseline: 4.47 µs
4.67 µs
(96.76%)
Adapter::RustBench📈 view plot
🚷 view threshold
4.53 µs
(+1.44%)Baseline: 4.46 µs
4.67 µs
(96.82%)
🐰 View full continuous benchmarking report in Bencher

This branch was successfully deployed

No deployments
Cloudflare — e064fbb1 Deployed Dec 1, 2026 by epompeii via Build / Build API Docker #3727
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.

1 participant