Hi Christopher,
if you are interested in the 1d problem, you might also consider a
spline fit of order 1, for example with scipy.interpolate, see [1].
Cheers
Klaus
[1]
https://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html#spline-interpolation-in-1-d-procedural-interpolate-splxxx
My students are using this and seem to like it:
https://jekel.me/piecewise_linear_fit_py/about.html
> Date: Tue, 1 Jun 2021 17:22:52 -0700
> From: Chris Barker
> To: Discussion of Numerical Python
> Subject: [Numpy-discussion] Best fit linear piecewise function?
> Message-ID:
> i58wz0