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

Home » Public Forums » archive » MPfit question
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 question [message #64691 is a reply to message #62623] Tue, 13 January 2009 22:41 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Jan 13, 2:33 pm, "j.coe...@gmail.com" <j.coe...@gmail.com> wrote:
> I'm fitting data to a gamma variate function using Craig Markwardt's
> MPFIT.  This has been working great except for a chronic error message
> that occurs once every 50 fits or so:
>
> MPFIT: Error detected while calling mpfitfun_eval:
> MPFIT: Array dimensions must be greater than 0.
> MPFIT: Error condition detected. Returning to MAIN level.
> MPFITFUN: Error detected while calling mpfitfun_eval: Array dimensions
> must be greater than 0.
> Attempt to subscript P with <INT      (       1)> is out of range.
>
> My five parameters are getting lost.  The parameters are first passed
> to MPFITFUN via the parinfo structure because some are constrained.
> Then the parameters are passed along by MPFITFUN to the user-supplied
> model function as a double array, p.  When the error occurs, the p
> array has shrunk from five doubles to just one NaN, as you can see
> from the abbreviated output reproduced at the end of this post.  The
> subscripting error happens when the user-supplied model function tries
> to subscript the suddenly nonexistent second element of p, which is
> supposed to have five parameters/elements (and had five elements at
> all previous iterations).  This can happen during any MPFIT iteration,
> but usually around iteration 4.
>
> Does anyone know what's going on?  I checked to make sure that there
> are no NaN values in the data, and that my gamma variate model
> function is not producing any NaN values at any iteration.  I have the
> latest version of the MPFIT library.   I've just been catching the
> error and fitting the problematic data with IDL's routine, but MPFIT
> does a much better job when it works for me.  Hopefully someone else
> who has encountered this issue knows what I am doing wrong.  Thanks.
>
> Iter      1   CHI-SQUARE =       9182.7891          DOF = 353
> P               DOUBLE    = Array[5]
> .
> .
> Iter      2   CHI-SQUARE =       6448.4258          DOF = 353
> P               DOUBLE    = Array[5]
> .
> .
> Iter      3   CHI-SQUARE =       8402.1122          DOF = 353
> P               DOUBLE    = Array[5]
> .
> .
> Iter      4   CHI-SQUARE =       1564.3159          DOF = 353
> P               DOUBLE    = Array[5]
> .
> .
> MPFIT: Error detected while calling mpfitfun_eval:
> MPFIT: Array dimensions must be greater than 0.
> MPFIT: Error condition detected. Returning to MAIN level.
> P               DOUBLE    =              NaN
> Attempt to subscript P with <INT      (       1)> is out of range.

Greetings--

I don't believe MPFIT should change the number of elements in the
parameter array P.

My first guess is that your user-function is redefining the P array.
Try doing a HELP on P at both the beginning and the end of your user
function to see if that's true.

Another possibility is to set !EXCEPT=2 to see if IDL will indicate
where the numerical exceptions first start to occur.

Finally, nothing beats good ol' stepping through line by line until
you find the culprit.

Craig
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Trouble writing very large files
Next Topic: Recording batch commands

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

Current Time: Fri Oct 10 05:51:43 PDT 2025

Total time taken to generate the page: 1.75165 seconds