Simultaneous fitting in IDL [message #66384] |
Thu, 14 May 2009 09:54  |
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
|
|
|