Piecewise-constant fitting

@stephenll, thanks for this very good advice.

There is the Julia Changepoints.jl package that implements the PELT technique. The results below are really good, but I was only able to get K=21 breakpoints after trial and error, with no constraints available on minimum segment size. JuMP’s heavy weapons seem to be more versatile.

Changepoints.jl code
using Changepoints, Plots

pelt_cps, cost = @PELT vec(y_data) Normal(:?, 0.02)
plot(y_data, c=:blues)
vline!(pelt_cps, c=:red, lw=0.4, ls=:dash, title="PELT Changepoints.jl, σ=0.025 (➡ K=21)", titlefontsize=9)
1 Like

Thanks, I wasn’t aware of this.

1 Like