0
$\begingroup$

I have a discrete signal. I want to do sinusoidal 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.

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

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).

$\endgroup$
  • $\begingroup$ ,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 $\endgroup$ – Shan Apr 18 '13 at 21:07
  • $\begingroup$ Wouldn't it be better to just find the frequency and phase using an FFT? $\endgroup$ – endolith Apr 19 '13 at 17:26
  • $\begingroup$ 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. $\endgroup$ – Matt L. Apr 20 '13 at 9:50
0
$\begingroup$

Assuming your signal is roughly sinusoidal to begin with:

If you have no clue what the frequency is, do a DFT on an interval large enough to contain a few cycles, sampled densely enough so you get at least 3 samples per cycle.

Find the peak bin. Find the bigger adjacent bin.

Apply this solution using the two bins.

If you know the frequency roughly, pick an interval with a whole number of cycles plus a half. Make sure you have at least 3 samples per cycle and then you only need to calculate the two adjacent DFT bins, not the whole DFT.

This solves for a best fit rather than iterating towards it.

The parameters you get are relative to the frame you use. I.e., the frequency is in cycles per frame and the time is zero at sample zero.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.