Skip to content

Piecewise linear regression (segmented least squares) algorithm.

License

Notifications You must be signed in to change notification settings

Bamboobill/piecewise-linearreg

 
 

Repository files navigation

Piecewise Linear Regression

A piecewise linear regression algorithm implemented in MATLAB. It uses dynamic programming to find the set of line segments with the lowest cost (sum of squared errors + λ × number of line segments).

How it works

  1. Sort the points by x-coordinate.
  2. Calculate the regression parameters (b0, b1) and sum of squared errors for every combination of leftmost and rightmost points.
  3. For k from 1 to the number of points, find the subsolution with the lowest cost.
  4. Work backwards to find the combination of line segments with the lowest cost.

Example output

Copyright Information

Copyright © 2017 Aidan Fitzgerald, GPL 3.0.

About

Piecewise linear regression (segmented least squares) algorithm.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • MATLAB 100.0%