PDA

Click to See Complete Forum and Search --> : [RESOLVED] Constrained Least Squares


VBAhack
Aug 23rd, 2007, 05:01 PM
I'm fitting data points with cubic polynomials. The standard linear least squares approach (ie. ATAc = ATy, where c are the polynomial coefficients and A is the matrix of basis functions) works just fine, but I want to guarantee that the curve go through the 1st and last points, which standard least squares doesn't do.

Anybody know how this is done from a mathematical standpoint? I can solve the problem using, for example, the solver within Excel, but I'm curious as to the math development/theory for this kind of problem. Anybody know of any reference that deals with this? :)

jemidiah
Aug 24th, 2007, 07:58 AM
Probably not what you're looking for, but here's a somewhat interesting and related idea.

Also, I'm not very familiar with linear algebra and the specifics of how polynomial fits are computed (Coming in 2008!). So I might say something trivial, or useless.


You could force-fit one point by translating everything over so that point is on the origin, and setting D->0 in your cubic polynomial, and then by translating everything back over.

Oooh, you could even do it again: after you've set D->0, translate everything again so the 2nd point is at the origin and restrict the constant term again to zero. Though... the constant term would then be a cubic function of A, B, and C, and setting it to zero would just add another equation to the mix equivalent to the previous one after some algebraic witchery.

Instead... you could translate the second point over to a *very* large x-value, assume the contribution from the quadratic, linear, and constant terms there are negligible, and solve for A. Of course this would only work as the translation->infinity, which probably isn't very practical.


In any case, you would have eliminated two unknowns from your cubic fit, possibly simplifying it--though linear algebra probably could do that brute force anyway (end of summer, I never really liked matricies, so I'm not gonna try to think if it could).

Perhaps the rest of the minimizing work could be done with Calculus?

VBAhack
Aug 24th, 2007, 04:10 PM
Thanks. I found what I was looking for. The key is a cubic poly form that goes through two points:

y = a(x-x0)2(x-x1) + b(x-x0)(x-x1)2 + y0(x-x1)/(x0-x1) + y1(x-x0)/(x1-x0)

jemidiah
Aug 28th, 2007, 05:18 AM
Cool, looks like I was on the right track at least. I'm happy about that