Initial Guess for Trigonometric Curve Fitting

approximationnonlinear optimizationpolynomialstrigonometric seriestrigonometry

I have from measurements data which should behave like a cosine function, but doesn't because of some physical effects.

For a cosine function with maximum $y_{\text{max}}$ and minimum $y_{\text{min}}$ and the phase $\varphi$, the cosine can be written as
$$ \frac{y_{\text{max}} – y_{\text{min}}}{2} \cos(\varphi) + \frac{y_{\text{max}} + y_{\text{min}}}{2}$$

I am using this for initial guess for the amplitude and offset of my algorithm (I'm fitting baiscally my measured data with a cosine function of the form above).

Now, I thought to model my measurements instead with a cosine + a second cosine function, so basically with a trigonometric polynomial of degree 2. So a polynomial of the form

$$ A_0 \cos(\varphi) + A_1 + A_2 \cos(2\varphi)$$
with Amplitude A. However, I have no idea how I could provide any first guess for the Amplitude $A_2$ (or $A_3$ if I would increase my degree). Is there any relation between the min and max values of the function and the high order amplitudes? As it is for a normal cosine case.

Best Answer

If you have $m$ data points $(\phi_i,y_i)$ and you want to fit the data according to $$y=A_0+\sum_{n=1}^p A_n\,\cos(n\phi)$$ you just face a multilinear regression $$y=A_0+\sum_{n=1}^p A_n\,t_n \qquad \text{where} \qquad t_n=\cos(n\phi)$$

So, just create the variables $$t_{1,i}=\cos(\phi_i) \qquad t_{2,i}=\cos(2\phi_i) \qquad t_{3,i}=\cos(3\phi_i)\qquad \cdots$$

There is no need for any initial guess.

Where the problem will be totally different is if you want $$y=A_0+\sum_{n=1}^p A_n\,\cos(\omega_n\phi)$$ with unknown $\omega_n$. This would require good estimates of the $\omega_n$'s but it is rather simple. The main difference will be the requirement of nonlinear regressions.

Related Question