Harmonic Analysis and Hidden Periodicities
The tide tables at any port are, at bottom, an act of harmonic analysis. The height of
the sea is modelled as a sum of a few dozen pure cosines — the pull of the moon, the pull of the sun,
their harmonics — each with its own frequency, amplitude and phase. Fit those constants once and you can
predict the tide years ahead. The same machinery finds the 24-hour rhythm in body temperature, the
annual swing in retail sales, the spin period of a distant star from its flickering light. Whenever you
suspect a series hides a clock, harmonic analysis is how you find it and measure it.
The model is a periodogram
made explicit: instead of scanning power at every frequency, we commit to a handful of
candidate frequencies and fit sinusoids there.
A series as a sum of sinusoids
We write the series as a deterministic sum of cosine–sine pairs plus a noise term:
x_t = \mu + \sum_{k=1}^{m}\big[\,a_k\cos(\omega_k t) + b_k\sin(\omega_k t)\,\big] + \varepsilon_t .
Each pair a_k\cos(\omega_k t)+b_k\sin(\omega_k t) is one sinusoid of amplitude
R_k=\sqrt{a_k^2+b_k^2} and phase
\varphi_k=\operatorname{atan2}(-b_k, a_k) — the cosine/sine form just spares us
fitting an awkward phase inside the trig. The picture below builds a signal from two such sinusoids: a
slow one and a faster one add to a single richer wiggle.
Fitting the amplitudes: regression made trivial by orthogonality
Fitting a_k, b_k looks like a big multiple regression of
x_t on a pile of sine and cosine columns. The magic is that when the
\omega_k are Fourier frequencies
\omega_k = 2\pi k/T, those columns are mutually
orthogonal over t = 1,\dots,T:
\sum_{t=1}^{T}\cos(\omega_j t)\cos(\omega_k t) = 0 \ \ (j\neq k), \qquad
\sum_{t=1}^{T}\cos(\omega_j t)\sin(\omega_k t) = 0 .
- Because the sinusoidal predictors are orthogonal, the least-squares estimates
decouple: each amplitude is a simple dot product,
\hat a_k = \tfrac{2}{T}\sum_t x_t\cos(\omega_k t),
\hat b_k = \tfrac{2}{T}\sum_t x_t\sin(\omega_k t) — no matrix inversion,
no interference between frequencies.
- The fitted power at \omega_k is exactly the periodogram ordinate:
I(\omega_k) = \tfrac{T}{4}\big(\hat a_k^2 + \hat b_k^2\big).
- Harmonic regression and the periodogram are therefore the same computation seen two ways.
So the periodogram is not a rival to sinusoidal regression — it is the sum of squares that
regression explains at each Fourier frequency.
Is a peak real? Fisher's test
A tall periodogram ordinate might be a genuine cycle or just the biggest of many random spikes. R. A.
Fisher answered the question exactly for the null of Gaussian white noise. Form the ratio of the largest
ordinate to the total,
g = \frac{\max_j I(\omega_j)}{\sum_j I(\omega_j)} .
Under white noise the distribution of this Fisher's g statistic
is known in closed form, so a p-value for "the biggest peak is just noise"
can be computed and a threshold set. A peak that clears Fisher's bar is a periodicity you can defend;
one that doesn't is grass. This is the disciplined version of "don't trust an unsmoothed peak".
Aliasing and the Nyquist frequency
Sampling has a hard ceiling. If you observe once per time step, the fastest cycle you can resolve is one
that completes every two samples — the Nyquist frequency
\omega = \pi radians per step (half a cycle per step, or half the sampling
rate). Anything faster does not vanish; it folds down and masquerades as a slower
frequency you can represent. Two cosines, one fast and one slow, can pass through the identical
value at every sampling instant:
- With unit sampling interval the resolvable band is
0 \le \omega \le \pi; \omega = \pi is the
Nyquist (folding) frequency.
- A true frequency f cycles/step above
\tfrac12 is aliased to
|f - 1|: e.g. 0.9 cyc/step is
indistinguishable from 0.1 cyc/step once sampled.
- No amount of later processing can undo aliasing — the high frequency is gone before the data are
recorded. The only defence is to sample fast enough (or filter before sampling).
A camera samples the world at 24 frames a second. If a spoked wheel turns just under one spoke-spacing
per frame, each frame catches the next spoke almost where the last one was — a hair behind — and
the eye stitches those frames into a slow backward rotation. The true motion (fast, forward) has
been aliased below the camera's Nyquist frequency into a slow motion of the opposite sign. It is exactly
the two-cosines picture above, playing at the cinema: an under-sampled fast cycle wearing the disguise of
a slow one.
Suppose you sample an electricity meter once an hour and "discover" a slow 12-hour swing. Before writing
it up, ask what fast cycles you couldn't see: a real 12-hour-and-a-bit fluctuation, or a
machine cycling every ~55 minutes, can alias straight into an apparent 12-hour rhythm. Because aliasing
happens at the moment of sampling, the fake slow cycle sits in your data looking utterly genuine — the
periodogram will show a clean peak at the wrong place. The only cures are physical: sample faster, or put
an anti-alias (low-pass) filter before the sampler. You cannot test your way out of it after
the fact.