# Quadratic curve fit while constraining a term

I get sets of points that are generally linear with slight curvature to them. We've been fitting quadratic curves to them which works fine if we have decent points across the range but if there are missing parts/outliers then the curve will fit well in that range but then veer off sharply.

Basically a very gradual curve that I'm only seeing/fitting sections of at a time.

I want to fit a "slightly" quadratic curve. I guess either hard constraints on the ax^2 term or maybe a penalty to keep a small as possible while fitting well. This way even if the fit isn't perfect the error is small.

Any advice on how to accomplish this would be appreciated.

EDIT: More information. This in image processing, the points are extracted from an image and I'm trying to fit a curve to them. If my extraction phase does a bad job and I only have, for example, noisy points on only 1/3 of the image then the fitted curve often will swing wildly and not fit well to the portions I have zero points in. The true model is a very gradual curve, that is, mostly linear with a slight possible bend. I'm trying to fit knowing that model. You can easily fit a parabola but that's an impossible real life answer. Trying to constrain that.

• It should be fairly simple to code up a linear model which only penalizes the quadratic term. Have you tried that? Nov 9, 2021 at 20:26
• "... I'm only seeing/fitting sections of at a time" suggests you want to fit a spline to your data. Some more guidance from you concerning what you actually need to accomplish would be helpful.
– whuber
Nov 9, 2021 at 21:11
• @whuber These are aerial images so the object in question spans multiple images but I'm working on an image at a time hence the "sections at a time". Nov 10, 2021 at 12:19