# doing sine regression to recover the paramters from a given signal

I have a discrete signal. I want to do sinusidal regression to estimate the parameters such as amplitude,phase, frequency etc It is important to note I only have the signal values and have no time when these values were recorded.

How could I possibly do the sine regression?

Thanks

• Are the time intervals between samples equidistant? – Matt L. Apr 18 '13 at 6:51
• @Matt, yes the time intervals are equidistant – Shan Apr 18 '13 at 14:54
• If there is additive noise, do least-squares regression. – Emre Apr 18 '13 at 18:35

If your samples are equidistant you can use a model function like $$\hat{x}(n)=a\sin(bn+c)+d$$ where $n$ is your sample index. You can compute the parameters $a,b,c,d$ by setting up an overdetermined nonlinear system of equations.

Let $x(n)$ be your signal. Then you'll have

$$a\sin(b\cdot 0 + c) + d = x(0)\\ a\sin(b\cdot 1 + c) + d = x(1)\\ a\sin(b\cdot 2 + c) + d = x(2)\\\vdots$$

(Of course, the equalities are only approximate equalities.) You can use a nonlinear method such as the Newton method to solve this nonlinear overdetermined system. The only problem is that you need a sufficiently good initial solution. Try to find a simple initial guess by inspection (if your data looks at all like a sinusoid ...). For $a$ and $d$ you could simply use

$$a_0 = \max(|x(n)|),\quad d_0 = \frac{1}{N}\sum_{n=0}^{N-1}x(n)$$

as initial guess ($N$ is the number of data points).

• ,thanks for the answer, I have done that, it did not work in start, i have restricted the x values to an interval 2.0 and equidistant, then it worked, any specific reason for this behavior? how could i know this interval – Shan Apr 18 '13 at 21:07
• Wouldn't it be better to just find the frequency and phase using an FFT? – endolith Apr 19 '13 at 17:26
• I'm not sure if an FFT could give better results than the standard sine regression I've described. I guess it all depends on the type of signal and on the noise. Anyway, an FFT could probably be used to get a reasonable initial solution for the nonlinear optimization routine. – Matt L. Apr 20 '13 at 9:50