Skip to content

Latest commit

 

History

History
18 lines (11 loc) · 712 Bytes

README.md

File metadata and controls

18 lines (11 loc) · 712 Bytes

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.