I am looking for an algorithm that will take data points and fit a cosine fuction to them. Anyone know of an algorithm in C? :confused: Thanks for your help!
Cosine fitting fuction
Started by Jiff, Aug 16 2007 12:51 PM
4 replies to this topic
#1
Posted 16 August 2007 - 12:51 PM
|
|
|
#2
Posted 20 August 2007 - 11:14 AM
Any ideas? Any help? :confused:
#3
Posted 21 August 2007 - 08:07 AM
I'm not aware of an algorithm, in general. I would start by doing research on fitting data to a cosine function in general, then worry about converting the algorithm to C.
#4
Posted 21 August 2007 - 11:14 AM
Hi WingedPanther. Thanks for your reply.
I am not worried the algorithm is in C right now. I can always convert it later as the end result must be in C. However, I am having trouble finding information on fitting data to a cosine function in general. Any tips on were I can find this information?
I am not worried the algorithm is in C right now. I can always convert it later as the end result must be in C. However, I am having trouble finding information on fitting data to a cosine function in general. Any tips on were I can find this information?
#5
Posted 22 August 2007 - 08:28 AM
I haven't found one, but here are some ideas to work with:
A cosine function has four parameters, giving it y = A cos(Bx + C) + D
Performing a linear regression y = Ax + B, A should be close to 0, and B will be D in the cosine function.
Using y=Ax+B, you can analyze the data values to find intervals that are above the line, which should allow you to compute B (from the average wavelength).
You can also use that analysis to determine the horizontal shift (thus computing C).
Finally, you can find the average of the peaks and troughs to compute A.
A cosine function has four parameters, giving it y = A cos(Bx + C) + D
Performing a linear regression y = Ax + B, A should be close to 0, and B will be D in the cosine function.
Using y=Ax+B, you can analyze the data values to find intervals that are above the line, which should allow you to compute B (from the average wavelength).
You can also use that analysis to determine the horizontal shift (thus computing C).
Finally, you can find the average of the peaks and troughs to compute A.


Sign In
Create Account

Back to top









