# Shape constrained curve fitting

This problem concerns fitting a curve to a set of data under a number of constraints.

Let $$f: \mathbb{R}^+ \to \mathbb{R}$$ be a strictly convex function with $$f(0) = 0$$. Suppose that, as data, one has $$N$$ triplets of the form $$(x_i, y_i, y_i^\prime)$$ where $$y_i = f(x_i)$$ and $$y_i^\prime = \frac{d}{dx_i} f(x_i)$$, i.e., for a few points we observe the function values and the derivatives. This observation is noisy, but the observation error is really small.

My objective is to "predict" the values of $$f$$ at a fine grid of values contained in the interval $$[\min(x), \max(x)]$$.

Things I've tried: (i) fit a generalised additive model (GAM) to the data $$\boldsymbol z = (\boldsymbol x, \boldsymbol y)$$ and ignore the derivative information; (ii) fit a convex Gaussian process by trying to enforce positivity of the second derivative (which is also a GP).

This second approach could be better done as I was not able to incorporate the derivative data into the modelling process.

What I am looking for is some hint on how to incorporate all of the information I have in order to obtain the best possible interpolator for my goal. Notice I don't really care about overfitting or other similar important concerns when doing modelling in general.

## Further details

Here are two plots of the data, differing only in how zoomed in/out they are

I'm happy to provide more details and edit my question accordingly.

• One approach is to spline the data, as described at stats.stackexchange.com/questions/428558
– whuber
Feb 28, 2020 at 15:16
• Thanks for the suggestion, @whuber. I copied their code over and ran on my own data, but things didn't look so rosy as the resulting interpolation did not look any better than GAM [in fact it was much worse]. To be clear, GAM works nicely, but I need even more precision, so I'm looking for something that can allow me to use all of the information available. Let me know if I can provide any more useful information. Feb 28, 2020 at 17:06
• The approach in my answer at that thread should work very well, because your data are more extensive and far smoother than the data I used to demonstrate its efficacy. I haven't tested the Kalman filter solution posted there but I like it because it ought to apply directly to your data (which have no repeated measurements).
– whuber
Feb 28, 2020 at 17:20
• It's not clear to me how to produce the plots you show in your post in that thread. Feb 28, 2020 at 17:51