Given a set of points , sorted by their -coordinates, the objective is to find a partition of these points into segments that minimise the loss function:
where:
is the sum of squared errors over all segments. For a single segment points from index to , the error is , where is the best fit line for that segment