views:

135

answers:

3

I have data I would like to plot, and more importantly, do a least squares regression on using cosines (instead of using polynomials): http://imgur.com/AkEaE.png

Any recommendations? Thanks.

A: 

You might find this demo Least Squares & Data Fitting helpful since it solves a few of your problems.

stacker
I've used that. Unfortunately, that is a regression that uses polynomials. I need one that uses cosines, fitting to this equation: http://imgur.com/AkEaE.png
Earl Bellinger
A: 

Just a bit of cautionary advice. Using a Fourier series makes sense if you think your underlying function has a cosine series as a basis; however, if you are using it as a basis for an arbitrary function (with unknown shape), you may do better trying to guess at a more specific underlying function type (polynomial, exponential, etc).

I did some constrained optimization on such a series, and the function wiggled around so much it was hard to say if my fit was meaningfull; my fit function had great number of local maxima.

Justin
Thanks for the tip. We're pretty sure the underlying function has a cosine series as a basis though.
Earl Bellinger
A: 

Probably the following page solves the regression part of your aim:

http://www.teneighty.org/software/index.html?f=fft&c=e98b8

zellus