Re: mpfitfun.pro [message #27248] |
Mon, 15 October 2001 07:40 |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
fskhk@puknet.puk.ac.za (Helena Kruger) writes:
> I'm using Craig Markwardt's fitting routine MPFITFUN.PRO. I use an
> expression called the Dorman function, to fit the given data points.
> I don't get a proper fit, doesn't matter which starting params I use.
> This is my code:
>
> function dorman, x,p
> return,P(0)*P(1)*148.1*(X^(-P(1)-1.0))*exp(-P(0)*X^(-P(1)))
> end
>
> start=[1.5D, -0.5]
> p=MPFITFUN('dorman',x,y,rerr,start)
> yy=dorman(x,p)
>
> oplot, exp(x), exp(yy), color = 150 ; using natural log axes.
>
> What am I doing wrong?
> Thanks for any help.
Hi Helena--
This is a very difficult question to diagnose, because of lack of
information. It is not even clear to me whether MPFITFUN is failing
yet.
Here are some possibilties to explore:
1. Are you sure you are plotting it correctly? "plot, exp(x),
exp(yy)" is not the way I *ever* do log-log plotting.
2. Before you fit, have you tried to plot the function with reasonable
parameters, to see if it makes sense?
3. Your function has a singularity at X EQ 0. This will confuse the
fitter. Be sure your X range is far removed from singularities.
4. Sometimes a function depends very weakly on a parameter, so weakly
in fact that the automatic derivative facility of MPFIT is not able to
compute a derivative for that parameter. One symptom of this is that
the fitter may return without appearing to iterate, ie, it returns the
START parameters.
The solution of this is to investigate the PARINFO keyword, using the
STEP or RELSTEP fields. This will allow you to set a step size for
the derivative computation. However, don't do this unless you really
need to, because it may lead to more problems if you're not careful.
Also, you can compute analytical derivatives if that will help (in
this case you must set AUTODERIV=0).
Hope these suggestions help!
Good luck,
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|