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

Home » Public Forums » archive » Re: mpcurvefit vs. a matlab fitting technique
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: mpcurvefit vs. a matlab fitting technique [message #61574] Wed, 23 July 2008 21:07
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
sheilakanani@googlemail.com writes:

>> But if I change the input even slightly eg [9.4,0.24,0.77,-1.5]
>> I get totally different values out, eg [7.7098139, 0.19333284,
>> 0.60223838, -0.85758867]
>>
>
> Sorry, typo, this should read:
>
> But if I change the input even slightly eg [9.44,0.24,0.77,-1.5]
> I get totally different values out, eg [7.7098139, 0.19333284,
> 0.60223838, -0.85758867]

This person also sent me a private email, which I
replied to. Here is what I wrote:

Without more information, I can offer only a few suggestions. First
of all, the different fit parameter sets you described *may* be a good
fit. MPFIT stops iterating when it achieves it tolerances, and cant
know how the previous fit did. If both are good fits, then that tells
you something about your model. Some other ideas about parameter
convergence are here:

http://cow.physics.wisc.edu/~craigm/idl/fitqa.html#parstep

It may be that you need to set PARINFO.STEP for some parameters.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: mpcurvefit vs. a matlab fitting technique [message #61606 is a reply to message #61574] Tue, 22 July 2008 09:46 Go to previous message
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
<sheilakanani@googlemail.com> wrote in message
news:117be385-ff64-4b09-9a74-7b053fe3ee31@m36g2000hse.google groups.com...
> Hi there,
>
> I am trying to run an IDL program using mpcurvefit. The same program
> was written in Matlab and used lsqcurvefit for the fitting. I am
> having some serious issues with mpcurvefit (although it is better than
> the IDL curvefit!) and was hoping you can help me resolve these
> issues.
>
> I put 4 coefficients into the fitting routine then mpcurvefit "spits"
> out the fitted values for these coefficients. However, the program is
> not stable at all. For example
>
> If I put [9.4,0.24,0.77,-1.5]
> into the routine
> I get [ 9.538911, 0.15903937, 0.72624838, -1.3497545] out.
>
> But if I change the input even slightly eg [9.4,0.24,0.77,-1.5]
> I get totally different values out, eg [7.7098139, 0.19333284,
> 0.60223838, -0.85758867]

What are the results with matlab for these two inputs?
And i'd also suggest doing about 100 other cases, for both IDL and matlab,
to get some measure of the stability if your systems.
Are both solutions iterating the same number of times, is one of
the algorithms hitting it maxint limit? what are the step sizes of the
iterations etc.

Use double precision everywhere )are there implicit floats in the idl
code?).

Since we don't know what you are fitting it is hard to say anything mroe.

Cheers,
bob
Re: mpcurvefit vs. a matlab fitting technique [message #61612 is a reply to message #61606] Tue, 22 July 2008 06:12 Go to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Jul 22, 5:55 am, sheilakan...@googlemail.com wrote:
>> But if I change the input even slightly eg [9.4,0.24,0.77,-1.5]
>> I get totally different values out, eg [7.7098139, 0.19333284,
>> 0.60223838, -0.85758867]
>
> Sorry, typo, this should read:
>
>  But if I change the input even slightly eg [9.44,0.24,0.77,-1.5]
> I get totally different values out, eg [7.7098139, 0.19333284,
> 0.60223838, -0.85758867]

I have found the mpfit routines to be quite good at minimizing square
errors. There are a lot of "tweaks" one can use, such as step-size,
to help the routines avoid local minima - take a look at the parinfo
keyword.

I will also depend a lot on the equation that you are fitting.
Perhaps the variables are slightly "mixed", or the numerical
derivatives are ill-conditioned (is that the right term?). If
possible, one can also use analytical derivatives with the mpfit
functions, which might help.
Re: mpcurvefit vs. a matlab fitting technique [message #61613 is a reply to message #61612] Tue, 22 July 2008 03:55 Go to previous message
sheilakanani is currently offline  sheilakanani
Messages: 2
Registered: July 2008
Junior Member
> But if I change the input even slightly eg [9.4,0.24,0.77,-1.5]
> I get totally different values out, eg [7.7098139, 0.19333284,
> 0.60223838, -0.85758867]
>

Sorry, typo, this should read:

But if I change the input even slightly eg [9.44,0.24,0.77,-1.5]
I get totally different values out, eg [7.7098139, 0.19333284,
0.60223838, -0.85758867]
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: help about annotate
Next Topic: Re: help about annotate

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

Current Time: Sat Oct 11 16:14:17 PDT 2025

Total time taken to generate the page: 0.87960 seconds