Section B.2 Fourier Analysis
Fourier analysis works on pretty much the same principle. Instead of using sine and cosine, it uses a complex exponential.
ws = np.exp(2 * np.pi * 1j * f * ts)
We can estimate the parameters by computing the dot product of the complex exponential with the signal (which is basically correlation).
$ c = 2 / len(ts) * np.vdot(ws, ys)
c
np.complex128(1.2602143401738164+0.68455041144776j)
The result is a complex number that represents the estimated amplitude and phase of the signal.
$ A_hat = np.abs(c)
phi_hat = np.angle(c)
A_hat, phi_hat
(np.float64(1.4341371792799409), np.float64(0.49760870975866645))
And the estimated values are the same as what we got from linear regression.
This works because \(e^{i\theta} = \cos\theta + i\sin\theta\text{,}\) so when we project the signal on a complex exponential basis, weβre effectively computing the sine and cosine components in a compact form.
