Re: Curve Fitting Question [message #1306] |
Tue, 14 September 1993 14:26  |
perry
Messages: 3 Registered: September 1993
|
Junior Member |
|
|
In article <1993Sep14.100111.1@aurora.alaska.edu>, ftdwh@aurora.alaska.edu writes:
|> The question I have is how to properly use the curvefit routine to fit a
|> function that I am defining. It is as follows:
|>
|> mclat = A1 + A2*cos(mlt + A3) + A4*cos(2*mlt + 2*A5) + A6*cos(3*mlt + 3*A7)
|>
|> where mclat is the magnetic co-latitude, mlt is an angular representation of
|> the magnetic local time.(This is a Fourier fit)
It should be pointed out that this problem can be recast as one that is linear
in all the fitted parameters, and thus, much easier to handle. In particular,
mclat = B1 + B2*cos(mlt) + B3*sin(mlt) + B4*cos(2*mlt) + B5*sin(2*mlt)
+ B6*cos(3*mlt) + B7*sin(3*mlt)
where B1 = A1, B2 = A2*cos(A3), B3 = -A2*sin(A3), and so on.
You solve for B1,..,B7 using a linear least squares fit and
then obtain A1,...,A7 from the B parameters using the defining relations.
It is generally fairly straightforward to construct the relevant matrix for
solving for the fitted parameters and then using one of the IDL routines
to solve for them (SVD and SVBKSB preferable, but there are simpler methods;
which is best depends on the specifics of your problem)
|>
|> I have in my data set the mclat and mlt, but I want to find the coefficients
|> A1-A7. Can I do this using the fitting routine in IDL? If I can, what are the
|> steps I need to follow? (As with most manuals they seem to be written for
|> somebody who already knows what they are doing. Along that train of thought
|> can any body recommend a book that might help those of us not fully
|> knowledgable in IDL)
|>
I'm not quite sure if you are saying that you are not knowledgeable about IDL
or fitting methods or both. If it is the fitting methods you are not sure
about, you do need to learn more. It is very easy to get wrong results with
fitting routines if you do not know what you are doing. This is especially
true when dealing with many fitted parameters and nonlinear least squares fits.
Numerical Recipes in FORTRAN (also versions for C and Pascal, I believe) by
Press, Teukolsky, Vetterling, and Flannery is popular and should serve as a
good introduction (though it has some detractors among the experts).
Perry Greenfield (perry @stsci.edu)
|
|
|