From: rusin@vesuvius.math.niu.edu (Dave Rusin)
Newsgroups: sci.math.num-analysis
Subject: Re: Help with curve fitting using least squares method
Date: 9 Oct 1996 13:31:13 GMT
In article <53eghi$jbf@camel1.mindspring.com>, wrote:
>I have a set of data that I would like to fit with curve of the form:
>
>y = A sin (theta + phi)
>
>where theta is the angle at which the measurement was taken, A is the
>amplitude of the sine wave, and phi is a phase lag or lead. Therefore
>I need to solve for the unknowns A and phi to give me the best fit
>curve. Anyone out there have some code that would do this??
Am I missing something here? Do ordinary regression of y against
sin(theta) and cos(theta) to get a good fit of the form
y = b sin(theta) + c cos(theta)
Then determine A and phi by solving the equations
A cos(phi) = b A sin(phi) = c
that is,
A = sqrt(b^2+c^2), phi = arctan(c/b) (choose appropriate branch)
dave