Past exam of the mathematics course of the University of Cambridge 2023 ii Paper 4 30J d Solution Created 2026-09-24 Updated 2026-10-03
For each , the displayed objective is the sum of the minimized linear-regression residual sums of squares on the prefix and suffix . Precompute prefix sums ofThis requires operations. The corresponding five sums over a suffix are obtained by subtracting a prefix sum from the total.
For any block of observations, these raw sums give in constant timeBy the formula for the residual sum of squares in simple linear regression, its minimized loss isHence both losses for a proposed take constant time. Evaluating their sum for and keeping the minimum is another scan, so the complete minimization uses computations.