From: Hans D Mittelmann Newsgroups: sci.math.num-analysis Subject: Re: Least squares fit to sinusoidal data Date: Tue, 04 Nov 1997 19:30:44 -0700 Marcus wrote: > > I have some collected data which I know theoretically should fit a > sinusoid. I need to write an algorithm to do this. I am familiar with > some linear regression techniques, but this one is non-linear, I think. > Could you tell me how to go about deriving the necessary equations to fit > the data? And, can I use some kind of modified least squares method? This > seems like a rather common thing to do in data analysis, but I am having > trouble finding the information necessary to derive the formulas. > The parameters I require from the data are the terms a,b,c,d in the > equation below. > y(x)=a+b*sin(c*x+d) > > Thanks, > Marcus Hi, for your purposes orthogonal distance regression may be the best approach and an excellent program for that is ODRPACK. A link to it and to GUI for it is at (go down a bit from there) http://plato.la.asu.edu/guide.html#lsq If you prefer C, the next link is to a C code. -- Hans D. Mittelmann http://plato.la.asu.edu/ Arizona State University Phone: (602) 965-6595 Department of Mathematics Fax: (602) 965-0461 Tempe, AZ 85287-1804 email: mittelmann@asu.edu