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

Home » Public Forums » archive » Re: MPFITFUN AND PARINFO
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: MPFITFUN AND PARINFO [message #48697] Wed, 17 May 2006 14:56 Go to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
JJMeyers2@gmail.com writes:
> Hello,
>
> I am trying to use MPFITFUN to fit the sum of 2 Gaussians to my data. I
> need both of the Gaussians to give curves with positive numbers because
> a negative value will not make physical sense. When I run the MPFITFUN
> it gives me 1 Gaussian that has all positive values and one Gaussian
> that some values are negative. I tried to use PARINFO to costrain the
> values for the second Gaussian but I think I am using it wrong.
> Here is what I did:
>
> guess_2g=[0.70,0.11,0.3,0.13,532.,1.]
>
> parinfo(5).limited(0)=1.
> parinfo(5).limits(0)=0.
>
> fit=mpfitfun('twogauss',X,Y,1,guess_2g,PARINFO=parinfo)
>
> and the error message i receive is:
> % Expression must be a structure in this context: PARINFO.
> % Execution halted at: fit.pro

Please note carefully that error occured in your script and not
MPFITFUN. You don't say where, but I assume it crashed at the point
where you try to assign to PARINFO.

You have to create the PARINFO structure before you can fill it.
Perhaps the easiest way to do this is

parinfo = replicate({fixed:0, limited:[0,0], limits:[0.D,0.D]},NPAR)

There are other PARINFO fields you can include if you want, but these
are pretty common. Put this statement before you try to assign to
PARINFO. You don't have to put a VALUE field if you don't want to, in
which case your GUESS_2G initial values will be used.

You should take some care about constraining all your amplitudes to be
positive. I can point to examples in the past where people did that,
then tried to average the amplitudes and came out with a highly biased
answer.

Happy fitting!
Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: MPFITFUN AND PARINFO [message #48780 is a reply to message #48697] Thu, 18 May 2006 09:01 Go to previous message
JJMeyers2 is currently offline  JJMeyers2
Messages: 12
Registered: October 2005
Junior Member
Thank you Graig for the response and the fitting routines of course!
It works fine now.

I would like to ask you how MPFITFUN handles the case when both parinfo
and start_parms are set. Does start_parms take precedent over parinfo?
What happens in the case that start_parms and parinfo are in conflict?
For example if start_parms=[2,1] and parinfo(1).limited(0)=1,
parinfo(1).limits(0)=2.

Thank you again,
JJM
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Determine Data relationship
Next Topic: Re: Question About Scatter Surface Pro (www.dfanning.com)

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

Current Time: Wed Oct 08 13:52:56 PDT 2025

Total time taken to generate the page: 0.00427 seconds