comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » mpfit: multivariate fit
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: mpfit: multivariate fit [message #54105 is a reply to message #53931] Mon, 21 May 2007 16:52 Go to previous messageGo to previous message
Richard French is currently offline  Richard French
Messages: 173
Registered: December 2000
Senior Member
Thanks, Craig -
I appreciate the clarification, and I'm glad the solution was so simple.
This probably deserves some clarification in the MPFIT documentation as
well, since it differs from the conventions of all other least squares
fitting routines I've used (such as the IMSL routine, or CURVEFI), and the
documentation in MPFIT.PRO for MYFUNCT seems to me to say the opposite of
what you did to fix the problem:

The confusion stems from just what the 'model' really means:

It states in the documentation that

Model=F(x,p)
dp(*,i) = FGRAD(x,p,i)
...
Return,(y-model)/err

Where FGRAD() is a user function which must compute the derivative of the
model with respect to the parameter P(i) at X..... DP(I,J) is the derivative
of the I'th point with respect to the J'th parameter."

Since MYFUNCT returns (y-model)/err, and dp is stated as being the
derivative array with respect to 'model' (not with respect to
(y-model)/err), it seems to me that the documentation is saying that the
'model' function with respect to which one should take derivatives is
model=F(x,P), not (y-F(x,P))/err.

Dick

On 5/21/07 2:13 AM, in article m28xbiembq.fsf@phloem.local, "Craig
Markwardt" <craigmnet@REMOVEcow.physics.wisc.edu> wrote:

>
> 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
>>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Idlgrsymbol size?
Next Topic: Re: write a root group to HDF5 file

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 16:03:54 PDT 2025

Total time taken to generate the page: 0.00465 seconds