# Does there exist a simple regression method to fit a single sinusoid period to a data set?

I'm currently working on a project where I want to fit a single sinusoid period to a data set. Essentially I have very good control/knowledge of the signal's dominant frequency, so I'm only sampling for a single period. What this leaves me with is the problem of determining the amplitude and phase offset in the presence of the sensor's noise.

I'm curious if anyone is aware of a easy to implement method for estimating these two parameters that is optimal in some sense. Most of my research results have been complex algorithms implemented in MATLAB which is not suitable for my application (I'm trying to measure this in real-time and don't have a license).

• Hi: you can use a regression model with no intercept so. $y_t = A (sin (\omega t) + \phi)$ where A is amplitude and $\phi$ is phase. There'a trig identity that wlll allow you to rewrite as a sine term + a cosine term. I forget what it is but it's in bloomfeld's text if you have that. Jun 7, 2019 at 20:42
• @markleeds I'm struggling to even get started with this. Do you have any resources on implementation?
– Izzo
Jun 9, 2019 at 19:14
• I'm sorry. I had the equation wrong. it should be $y_t=A \times sin(ω t+ϕ)$ where A is the amplitude and ϕ is the phase. Can you get your hands on Peter Bloomfield's "Fourier Analysis of Time Series" because the gory details are nicely explained in there. I honestly wouldn't do it justice trying to explain it here. It's essentially a regression where the LHS contains the value of the sinusoid at different values of $t$. Jun 10, 2019 at 0:39

• ah, upon re-reading: You just recommend correlating with the appropriate $e^{j2\pi \frac f{f_s} n}$. That's the right way to go! Jun 8, 2019 at 12:06