-1

I have a set of points x,y for which I am trying to fit a quadratic relationship so,

y = ax^2 + bx + c

I also have have some equality constraints on a,b,c, for instance,

b=-a*K ( where K is a constant)

What might be the easiest way to solve this problem?

Ok so here is my effort on this: I can define an error function and define the constraints as penalty terms, and use a quadratic optimizer, I was curious if someone had an even easier way. Perhaps using something built-in, as far as I know, there are no standard built-in ways to do it.

Farmer Joe
  • 6,020
  • 1
  • 30
  • 40
ganesh reddy
  • 1,842
  • 7
  • 23
  • 38
  • You could look at the [scipy](http://docs.scipy.org/doc/scipy/reference/optimize.html#module-scipy.optimize) library. If it suits your needs, your question could be a [possible duplicate of this question](http://stackoverflow.com/questions/16541171/how-do-i-put-a-constraint-on-scipy-curve-fit) – Farmer Joe Dec 19 '14 at 16:55

1 Answers1

1

If you know the constraint on one parameter in terms of the others explicitly (as in your example b=-a*K), you should remove this parameter (b in your example) from the model before doing the fitting. In your example, I would write the model as

y = a (x^2 - K x) +c,

and fit the parameters a and c. This is still a linear fitting and should be easily solved by the same fitting routine as you use for the y = a x^2 + b x + c model.

You might have simplified the example too much from your actual problem. If that is the case, and if it is not easy to solve the constraint for one parameter in terms of the others, you may introduce a Lagrange multiplier. A key phrase, 'constrained optimization', might help you.

norio
  • 3,652
  • 3
  • 25
  • 33