Fitting an Escalier to a Curve
Sebastien Bossu, Andrew Papanicolaou, Nour El Hatto
TL;DR
The paper addresses approximating a target function $f$ in $L^2([a,b])$ by an escalier (step) function with $n$ steps, optimizing the fit by solving a linear LS subproblem when step positions are fixed and then optimizing the knot locations via nonlinear first-order conditions. It introduces a recursive, sweep-based optimization algorithm that recovers the global optimum by exploiting a three-term recurrence for the knots and a terminal condition, and provides a detailed numerical implementation with tests on a mix of smooth and discontinuous functions. Theoretical results include an explicit linear LS solution with a tridiagonal inverse Gram matrix, an $R^2$-based objective, and asymptotic/error bounds showing $O(1/n)$ SSE convergence under regularity; the nonlinear stage yields convergence characteristics and a practical algorithm, while numerical experiments demonstrate speedups over brute-force in low dimensions and scalable performance for higher step counts, highlighting interplay between precision, tolerance, and function structure. The work offers a principled, parsimonious approach to piecewise-constant approximation in $L^2$ with potential relevance to activation-function modeling, Haar-like decompositions, and fast surrogate fittings in signal processing and ML contexts, complemented by open-source C++ code.
Abstract
We analyze the problem of fitting a fonction en escalier or multi-step function to a curve in L^2 Hilbert space. We propose a two-stage optimization approach whereby the step positions are initially fixed, corresponding to a classic linear least-squares problem with closed-form solution, and then are allowed to vary, leading to first-order conditions that can be solved recursively. We find that, subject to regularity conditions, the speed of convergence is linear as the number of steps $n$ goes to infinity, and we develop a simple algorithm to recover the global optimum fit. Our numerical results based on a sweep search implementation show promising performance in terms of speed and accuracy.
