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

Home » Public Forums » archive » Problems getting CURVEFIT to work
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
Problems getting CURVEFIT to work [message #32860] Tue, 12 November 2002 15:24 Go to next message
Jonathan Greenberg is currently offline  Jonathan Greenberg
Messages: 91
Registered: November 2002
Member
Hi there, I'm trying to use CURVEFIT to fit data to a decay function of the
form:
f(x) = a(1-e^(bx))+c
My code is as follows:

pro decayfunc, X,A,F,pder
bx=EXP(A[1]*X)
F=A[0]*(1-bx)+A[2]
if N_PARAMS() GE 4 THEN $
pder=[[1-bx],[-A[0]*X*bx],[replicate(1.0,N_ELEMENTS(X))]]
end

X=[30185.0,33897.0,35089.0,35377.0,35665.0]
Y=[0.3002,1.3849,1.3004,1.226,1.3118]
A=[1.25,-1.0,-0.1]
weight=[1.0,1.0,1.0,1.0,1.0]
yfit=CURVEFIT[X,Y,weights,A,SIGMA,FUNCTION_NAME='decayfunc', /DOUBLE]

I get the error:
CURVEFIT: Failed to converge- CHISQ increasing without bound.
and the SIGMA values are:
.44721360,Infinity,.44721360

The plot of the data looks like it should fit a decay equation, but CURVEFIT
can't seem to determine the parameters. I've tried a number of different
starting values for A to no avail. Any suggestions?

--j

--
Jonathan Greenberg
Graduate Group in Ecology, U.C. Davis
http://www.cstars.ucdavis.edu/~jongreen
http://www.cstars.ucdavis.edu
AIM: jgrn307 or jgrn3007
MSN: jgrn307@msn.com or jgrn3007@msn.com
Re: Problems getting CURVEFIT to work [message #32876 is a reply to message #32860] Fri, 15 November 2002 20:38 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"Pavel A. Romashkin" <pavel_romashkin@hotmail.com> writes:

> Jonathan Greenberg wrote:
>>
>> Hello again Craig:
>>
>> You MPCURVEFIT function is terrific! I've started using it instead of
>> CURVEFIT. One quick question, how does it deal with NaN values? I started
>> including NaN values in my regressions, and I noticed some strange behavior
>> from the output -- ideally it should just ignore the X,Y that has a NaN for
>> the X value, but is this actually the case?
>
> Aha! This handling of NANs is the only part I couldn't figure out why it
> was not there.
> All I do is filter my own data for NANs before fitting.
> I guess Craig got distracted and didn't put WHERE(FINITE()) into his code...
> And of course, the program is excellent. No question there.

Hi Pavel--

There is no formal requirement that X and Y have the same dimensions
for most of the MPFIT family routines. Thus, doing the kind of
filtering you suggest gets a little tricky.

In more recent versions of MPFIT, I actually check for NaNs or
Infinities, and notify the user of a problem. If you have NaNs, that
is a problem. If certain points are to be ignored, then set their
WEIGHTS equal to zero. I don't think that CURVEFIT handles NaNs
either. Not that that's a good excuse (:-) but I think it's better
for the user to be explicit about what to do.

Happy fitting!
Craig


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: Problems getting CURVEFIT to work [message #32884 is a reply to message #32860] Fri, 15 November 2002 15:22 Go to previous message
Pavel A. Romashkin is currently offline  Pavel A. Romashkin
Messages: 531
Registered: November 2000
Senior Member
Jonathan Greenberg wrote:
>
> Hello again Craig:
>
> You MPCURVEFIT function is terrific! I've started using it instead of
> CURVEFIT. One quick question, how does it deal with NaN values? I started
> including NaN values in my regressions, and I noticed some strange behavior
> from the output -- ideally it should just ignore the X,Y that has a NaN for
> the X value, but is this actually the case?

Aha! This handling of NANs is the only part I couldn't figure out why it
was not there.
All I do is filter my own data for NANs before fitting.
I guess Craig got distracted and didn't put WHERE(FINITE()) into his code...
And of course, the program is excellent. No question there.
Cheers,
Pavel
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: calling a function in herself
Next Topic: How to smooth lines in plots

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

Current Time: Wed Oct 08 15:17:44 PDT 2025

Total time taken to generate the page: 0.00571 seconds