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

Home » Public Forums » archive » Re: NaN & mpfit question..
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: NaN & mpfit question.. [message #51035] Tue, 31 October 2006 09:15
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"D.Kochman@gmail.com" <D.Kochman@gmail.com> writes:

> I understand this is fairly well covered territory, however, I couldn't
> find a solution by searching through the archives.
>
> Anyways, as I call mpfit.pro, it goes into an infinite loop where I can
> only break it using the ctrl+break. I was curious as to what was
> causing this and it just keeps cycling with the same number values for
> the parameters, and Chi-Squared=NaN

MPFIT should max out at 200 iterations by default. You can change
this with the MAXITER parameter.

> So this got me thinking that somehow I was giving mpfit an array with
> NaN, but I can't figure out where. I even tried a hackish type thing
> to force NaNs to be zero, but still no luck.

The public version of MPFIT checks all input for NaNs and infinite
numbers, and quits if it finds any. This suggests that the NaN is
arising within MPFIT. One possibility is that the finite differencing
algorithm for computing derivatives is failing. In that case, you may
have to set the derivative parameters (STEP, RELSTEP) manually.

Like any debugging operation, take the process in steps. First see if
the model function itself is producing NaNs by itself. Then try
fitting one parameter at a time, and check whether that produces NaNs.
Set !EXCEPT = 2 and see where the errors start. And so on.

> So is there something else that I'm missing? dg.file1 is the one that
> ends up getting returned to mpfit.pro at the (y-f)/err

What happens when (Y-F) and ERR are both zero?

Good luck!
Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: NaN & mpfit question.. [message #51113 is a reply to message #51035] Sun, 29 October 2006 17:08 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
D.Kochman@gmail.com writes:

> So is there something else that I'm missing? dg.file1 is the one that
> ends up getting returned to mpfit.pro at the (y-f)/err

It would help to know the min and max values of your X array,
and what type of model you are trying to fit. Is it a log
or exponential function? Are there any negative values in
your X array? Etc.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: MPFIT2DFUN
Next Topic: Re: MPFIT2DFUN

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

Current Time: Wed Oct 08 19:21:47 PDT 2025

Total time taken to generate the page: 0.00539 seconds