# Fitting a Sine wave with varying frequency (almost random with time)

Although I am using software and code for this problem , I figured my issue is more mathematical. I am trying to fit a sine wave to some (noisy) data. When you look at the data it does resemble a sine and in theory it should have a fixed Frequency. However due to noise the frequency is not constant at all (it has small random shifts). Therefore I want to find a sine equation whose frequency varies.

I was thinking of an equation of the sort:$$Asin(ax^n + bx^{n-1}+ ... +z)$$ where the frequency is a polynomial function of degree $n$. However This does not seem to work. My question is simple since I only want to know If i'm on the right track. Does a polynomial frequency make sense for a sine which has varying (random) frequency?

• Curve fitting problem? – user202729 Dec 18 '17 at 12:09
• Since they are random are you not better studying the frequency shifts as a probability distribution function. Then you can see if there is a single peak or double peak in the distribution. And make a simple statistical model based on that. If its a random process you won't be able to predict in advance what will happen so extrapolation techniques using polynomial curve fitting are not that useful to this problem. – James Arathoon Dec 18 '17 at 12:40
• Ideally I do not split the sinusoid but rather fit it as a single sine in the form I stated above. This is due to the fact that I am using a least squares method to fit the curve (meaning that any external noise not part of the sine..which is also possible will not have as much weight on the sine fit) @JamesArathoon the process is not random I already have the sine data. what is 'random' is the frequency i.e. each wavelength of my sine is a bit noisy therefore it is neither constant nor decreasing or increasing steadily. – user134132523 Dec 18 '17 at 18:05
• If you are taking n time units of data and least squares fitting a sine wave to this data you then have a frequency data point. Then after doing this m times you will have m frequency data points distributed somehow around the mean frequency. You can then draw a graph of how these frequency data points distribute themselves around the mean frequency. You can also study the rate of drift in frequency and plot that distribution as well. Assuming the rate of drift in frequency is a random process as well. – James Arathoon Dec 18 '17 at 18:46
• The main question is if the guessed form of function $y(x)\simeq Asin(ax^n + bx^{n-1}+ ... +x)$ is valid to fit your data. Can you edit an example of data to, at least, check in a typical case. – JJacquelin Nov 5 '18 at 14:34