Piecewise-constant fitting

Oh, I see — what you want is not piecewise-constant interpolation, but rather piecewise constant least-square fitting. This seems similar to this question, so probably you can use related techniques: Piecewise linear regression with automatic knot selection

1 Like