Re: mpfit: multivariate fit [message #54124 is a reply to message #53931] |
Sun, 20 May 2007 23:13  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
Richard, you sent me your code off-line.
Yes, there was an obvious problem, which is that your derivatives were
computed from d(MODEL)/d(P[i]).
However, the "user" function for MPFIT is always (DATA-MODEL)/SIGMA [*].
This means that the derivative is actually [ -d(MODEL)/d(P[i]) ]/SIGMA.
When I inserted a negative sign in your derivatives, the fit then
turned out fine.
Craig
[*] - This is true whether the user function is regular or "(EXTERNAL)".
"Richard G. French" <rfrench@wellesley.edu> writes:
> On the subject of MPFIT, I'm trying to implement the '(EXTERNAL)' function
> option (the case where the user does not supply a function to be called by
> MPFIT itself, but is expected to supply function values and a jacobian
> matrix in each call to MPFIT). I'm trying to do this with a very simple
> polynomial function for which the partial derivatives are very easy to
> compute, but the fitted parameters are not the correct values, the number of
> degrees of freedom returned is a negative number, and in general I am
> clearly not getting things to work.
>
> In trying to debug this, I found what looks like an undocumented keyword:
> EXTERNAL_INIT whose purpose is a bit obscure to me. I tried fiddling with
> this but it did not fix the problem
>
> Does anyone (Craig or someone else) have a simple example of MPFIT that uses
> the EXTERNAL option? If so, I'd be grateful if you would send it along. If
> not, then I can post my failing example so that someone can tell me what I
> am doing wrong.
>
> Thanks very much.
>
> Dick French
> rfrench@REMOVEwellesley.edu
>
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|