How this calculation works
Change-point segmentation finds a piecewise-constant mean description of an ordered series. The calculator uses a complete bounded dynamic program to choose break positions under a selected per-change penalty and minimum segment length. It reports segment means and the full penalized objective, without treating every selected break as a statistically established real-world event.
min_partition Σ_segments SSE(segment)+penalty×number_of_changes.A worked example
For 1,1,1,5,5,5 with minimum length two and penalty one, two constant segments have zero within-segment error and one change. Their objective is one. A single segment has mean three and squared-error cost 24, so the one-change partition wins.
Good to know
Squared-error mean changes only, at most 300 observations. The penalty and minimum length are user assumptions. No automatic significance calibration, variance-change model, causal-event inference or future prediction. Ties can yield several equally optimal partitions.
Reference: Ruptures change-point model and cost definitions (opens in a new tab) ↗
The objective balances fit against extra segments
Within each segment, the fitted constant is the segment mean and its cost is the sum of squared deviations. Adding another boundary can only improve the unpenalized fit, so a per-change penalty is needed to express the preference for a simpler segmentation. Penalty units are squared response units, not time units.
Scaling every response by a factor multiplies squared-error costs by the factor squared. To obtain an equivalent segmentation after such a unit change, the penalty must change by the same square. Leaving the numeric penalty fixed would alter the model-selection tradeoff, even though the ordered pattern of observations looks identical.
The Trailing moving average forecast calculator covers the nearby task. Segmentation selects structural break locations using a global objective rather than smoothing or forecasting.
Minimum segment length changes the feasible search
Dynamic programming considers every permitted preceding segment endpoint and stores the best objective for each prefix. Prefix sums provide segment means and squared-error costs without repeatedly scanning every candidate interval. Reconstruction follows the saved optimal predecessor indices, giving actual segment boundaries rather than just a final objective value.
A minimum length excludes very short segments before optimization. It is not applied afterward by merging inconvenient results, which could destroy optimality for the stated constraints. If several partitions have the same objective, the deterministic tie behavior returns one of them; the page does not claim the boundary locations are uniquely identified.
A selected break is a model description
The algorithm models changes in a piecewise-constant mean. A gradual trend, changing variance or isolated outlier can lead it to introduce boundaries even when no abrupt physical mean change occurred. Examining the original series and choosing a justified cost model are separate steps that the objective certificate cannot replace.
Small examples can enumerate all legal partitions and compare their objectives with the dynamic program. Such checks prove the implementation solves its bounded optimization problem, not that the penalty has a universal false-positive rate. The returned segment means describe observed intervals and are not a forecast for the next unobserved period.
Derive the cost of a candidate segment
For observations from index a through b, the best constant mean is their arithmetic average. Their segment cost is Σy²−(Σy)²/m, where m is the segment length. Prefix sums let the algorithm evaluate that cost without refitting every segment from scratch. The total objective adds those costs and one penalty for each change between adjacent segments.
Dynamic programming compares every allowed final-segment start against the best earlier partition. This gives a global minimum of the stated bounded squared-error objective, not merely a greedy split with the largest immediate improvement. The minimum-length control removes short segments from the candidate set and can change the optimum even when the penalty is unchanged.
See exactly when the default split disappears
For 1,1,1,5,5,5, one segment has mean 3 and SSE 6×4=24. Splitting after the third value gives means 1 and 5, SSE zero, and one change penalty. With penalty 1 the split objective is 1, so it beats the unsplit objective 24.
With penalty 25, the one-segment fit wins instead. At penalty 24 both partitions have equal cost, and the implementation may return one of them according to its tie handling. This threshold is an objective comparison, not a statistical significance boundary. Multiplying all observations by ten multiplies SSE by 100, so an equivalent penalty must also be multiplied by 100.
Translate change indices back to the observations
The table uses zero-based inclusive segment endpoints. A first segment ending at index 2 contains the first three observations; a next segment starting at index 3 begins with the fourth. If your series has dates, map indices back to those dates outside the form. The algorithm sees equally ordered numeric positions, not gaps in a calendar.
A detected boundary localizes a change in the fitted mean approximation. It does not identify the exact moment of an external event or distinguish its cause. Delayed reporting, smoothing and multiple simultaneous changes can shift an apparent boundary. Preserve the original observation order; sorting the values converts a time-segmentation question into a different problem.
Distinguish mean changes from other nonstationarity
A variance increase, isolated outlier or smooth trend can be approximated by additional constant-mean segments even without a sudden mean shift. The model does not explicitly fit variance changes or robust losses. Inspect the raw series and the segment residuals before describing every returned boundary as a regime change.
Try a justified range of penalties and minimum lengths, keeping a record of which boundaries remain stable. Repeated tuning on the same series does not produce a calibrated false-positive rate. If formal uncertainty or online monitoring is required, use a method designed for that question. This offline segmentation finds the optimum for the supplied complete series and does not predict when another change will occur.
A few questions, answered
Does a selected change prove a real event?
No. It is optimal under the chosen squared-error cost and penalty, not a causal conclusion.
How should penalty change with measurement units?
Multiplying responses by c requires multiplying penalty by c squared for an equivalent objective.
Is the penalty charged for each segment?
The reported objective uses one penalty per change, so K segments incur K−1 penalties. The initial segment is not an extra change.
Does increasing the penalty always preserve the same boundaries?
It discourages more changes, but the optimal boundary locations can move. Do not assume a higher-penalty partition is always obtained by simply deleting earlier boundaries.