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

Home » Public Forums » archive » Simultaneous fitting in IDL
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
Simultaneous fitting in IDL [message #66384] Thu, 14 May 2009 09:54 Go to next message
Gianluca Li Causi is currently offline  Gianluca Li Causi
Messages: 21
Registered: August 2005
Junior Member
Hi all,
I need to *simultaneously* fit two sets of data, Y1 and Y2, with two
functions, F1(X,P) and F2(X,P), having the same set of parameters P,
by using the routine LMFIT.

In order to do this I join the two datasets in a uniq vector Y=[Y1,Y2]
and do the same for the model F=[F1,F2], as suggested also by Craig
Markwardt in a past thread in this group:
http://groups.google.com/group/comp.lang.idl-pvwave/browse_t hread/thread/ba341b5169e7557f/498234b82c67279f?hl=en&lnk =gst&q=lmfit#498234b82c67279f

But my datasets contains a different number of points, N1 and N2, with
N2<<N1, so that the smaller one is almost neglected because its weight
in the uniq vector Y is proportional to N2 / N1.

SO THAT: I've tried to multiply each error vector by the SQRT of its
fraction:

Y1_err *= SQRT(N1 / (N1+N2))
Y2_err *= SQRT(N2 / (N1+N2))

and now I get a nice fit for the two dataset simultaneously!

BUT: when I compute the Reduced ChiSquare = ChiSquare / (N1 + N2 -
N_parameters) I get a completely wrong result (vey high, far from
1.0), due to my modification of the true error vector !

THUS: what I can do ?
One idea is to force the Y1 and Y2 vectors to have the same number of
elements M, which must be the minimum multiple of both N1 and N2, but
it could be a very large number.....


Could anybody help me ?!
Thanks a lot!
Gianluca
Re: Simultaneous fitting in IDL [message #66484 is a reply to message #66384] Wed, 20 May 2009 07:05 Go to previous message
Gianluca Li Causi is currently offline  Gianluca Li Causi
Messages: 21
Registered: August 2005
Junior Member
Dear Allan,
thanks a lot for your test procedure that I've improved to check
what's happening with my data: YOU'RE RIGHT and I WAS WRONG !!

In fact, the test procedure clearly shows that in my limiting
hypothesis of two functions depending on complementary parameters the
fit is good without the need to modify the data errors as I did: I've
realized that I was fitting my data with an incorrect function and I
was forcing the fit.
In fact I've realized that my observable, measured in different times,
had changed with time, while I assumed it to be static during all the
measurements; so that my data couldn't be fitted by a single set of
parameters, but I must divide the data in bunches of smaller time
intervals.

Thanks a lot for your help, which better clarify to me the data
fitting task.
Best regards
Gianluca
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: machine precision
Next Topic: Windows XP backing store error

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

Current Time: Fri Oct 10 18:10:35 PDT 2025

Total time taken to generate the page: 1.19940 seconds