Re: mpfit and linear equality constraints [message #79152 is a reply to message #79065] |
Mon, 30 January 2012 13:56  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
Greetings--
On Jan 30, 11:32 am, mats.lofd...@gmail.com wrote:
> I want to do non-linear model fitting with linear equality constraints and I just want to check that I've understood the mpfit "tied" keyword functionality correctly. Am I correct in believing it does not use the theory for linear equality constraints at all, it just removes the tied parameters from the problem and calculates them afterwards from the non-tied parameters?
You are correct that MPFIT does the former, not the latter.
> By "theory for linear equality constraints" I'm referring the procedure ...
...
> If I'm right, I'd be interested in pointers to IDL code implementing this kind of processing. Particularly if it does it and still uses mpfit for the actual fitting once the constraints part is out of the way.
I think you can accomplish some of what you want to do if you impose
constraints as additional equations in the problem. I outlined how
one can do this in my 2009 talk at IDL Visualize. [*] You need to
think of your N data points as N equations (to be solved in a least
squared sense). Adding more constraints is just adding more equations
to the list.
Basically, if you have N data points and M constraints, your user
function needs to compute N+M residual values.
The first N residuals are just the standard (data-model) residuals.
The following M residuals are the result of computing your constraint
equations. MPFIT doesn't care which is which.
The M constraints should be expressed as f(p) = 0, (where p =
parameters). For example if your constraint is P[0] EQ 4*P[1], it
needs to be re-expressed as P[0] - 4*P[1] EQ 0. MPFIT just solves
systems of equations where {f_i(p) = 0}, so if you can express your
constraints in the same form it will do the trick. You may need to re-
scale the constraint equations so that their residuals are comparable
to the N data constraints.
MPFIT solves the equation by orthogonal decomposition, so adding
constraint equations to the problem should achieve what you want to
do.
Best wishes,
Craig
[*] "Equation Solving with MPFIT," 2009 "IDL Visualize" workshop
http://www.physics.wisc.edu/~craigm/idl/fitting.html
|
|
|