← Notes · December 2026
The periodogram, its distribution, filters, harmonics, coherence and the Wiener filter, with proofs, and why a single regression correction cannot fix errors that depend on frequency.
A scatter plot of a low-cost sensor against a reference monitor gives one number: how well they agree overall. But pollution varies on many time scales at once, from traffic peaks lasting hours to seasonal cycles, and a sensor can be accurate on some scales and poor on others. Spectral analysis splits the variance of a time series by frequency, so agreement can be checked scale by scale. These notes collect the main results, with proofs where they are short.
Let \(x_t\) be a weakly stationary series with mean \(\mu\) and autocovariance \(\gamma(h) = \operatorname{Cov}(x_{t+h}, x_t)\). If \(\sum_h|\gamma(h)|<\infty\), its spectral density is
\[ f(\nu) = \sum_{h=-\infty}^{\infty} \gamma(h)\, e^{-2\pi i \nu h}, \qquad \nu \in [-\tfrac12, \tfrac12], \qquad \gamma(h) = \int_{-1/2}^{1/2} f(\nu)\, e^{2\pi i\nu h}\, d\nu . \]Frequency \(\nu\) is in cycles per time step (per hour for hourly data), and the period is \(1/\nu\). Setting \(h = 0\) gives \(\operatorname{Var}(x_t) = \int f(\nu)\,d\nu\): the spectral density says how the variance is spread over frequencies.
From data \(x_0,\dots,x_{N-1}\), the periodogram at the Fourier frequencies \(\nu_k = k/N\) is
\[ I(\nu_k) = \frac1N\Big|\sum_{t=0}^{N-1} x_t\, e^{-2\pi i \nu_k t}\Big|^2 . \]Proof. The vectors \(e_k = (e^{2\pi i kt/N})_{t}\) are orthogonal with \(\|e_k\|^2 = N\). Writing \(X_k = \sum_t x_t e^{-2\pi ikt/N}\), Parseval's identity gives \(\sum_t x_t^2 = \frac1N\sum_k |X_k|^2 = \sum_k I(\nu_k)\). The \(k=0\) term is \(N\bar x^2 = 0\). \(\square\)
Proof. Since \(\sum_t e^{-2\pi i\nu_k t} = 0\) for \(k\neq0\), subtracting \(\bar x\) does not change \(X_k\). Expand \(|X_k|^2 = \sum_{s,t}(x_s-\bar x)(x_t-\bar x)e^{-2\pi i\nu_k(s-t)}\) and group the terms by the lag \(h = s-t\). \(\square\)
So the periodogram is the sample version of the spectral density. It is, however, a noisy one.
Proof. Write \(X_k = A_k - iB_k\) with \(A_k = \sum_t x_t\cos(2\pi kt/N)\) and \(B_k = \sum_t x_t\sin(2\pi kt/N)\). For \(0 Remark (general series). The same picture holds approximately for linear processes with a smooth spectral density: for fixed frequencies \(0<\nu_1<\dots<\nu_r<\tfrac12\), the values \(I(\nu_j)/f(\nu_j)\) are asymptotically independent \(\mathrm{Exp}(1)\) (Brockwell and Davis, 1991, Ch. 10). Hence \(\mathbb E\,I(\nu)\to f(\nu)\), but \(\operatorname{Var} I(\nu) \to f(\nu)^2\), which does not shrink as \(N\) grows. The raw periodogram is asymptotically unbiased but not consistent. Averaging \(L\) approximately independent values (neighbouring frequencies, Welch segments, or separate sites) reduces the variance to about \(f^2/L\). Proof. \(\gamma_y(h) = \sum_{j,l} w_j w_l\,\gamma_x(h-j+l)\). Substituting \(\gamma_x(u) = \int f_x(\nu)e^{2\pi i\nu u}d\nu\) and summing over \(j\) and \(l\) gives \(\gamma_y(h) = \int |H(\nu)|^2 f_x(\nu)\, e^{2\pi i\nu h}d\nu\). \(\square\) For example, the KZ components of the previous note have spectra \(|H_m|^{2k} f\) and \(|1-H_m^k|^2 f\). Filtering never creates power at a frequency; it only rescales what is there. Proof. A sequence with period \(P\) is a vector in \(\mathbb C^P\), and the \(P\) vectors \((e^{2\pi i nt/P})_{t=0}^{P-1}\) form an orthogonal basis (the discrete Fourier basis). Over \(N = MP\) samples, \(\sum_t e^{2\pi i nt/P}e^{-2\pi ikt/N}\) vanishes unless \(k = nM\), i.e. \(\nu_k = n/P\). \(\square\) Remark (interpreting peaks). For hourly data with a daily cycle (\(P = 24\)), Lemma 5 says a single daily pattern produces peaks at 24, 12, 8, 6 and 4.8 hours unless its shape is a pure sinusoid. A daily profile with morning and evening rush hours already has strong 12 h and 8 h peaks. So a peak at 8 or 12 hours can come from a separate process, or from the shape of the daily cycle. Telling them apart needs extra information, such as comparing weekdays with weekends, or summer with winter. Model a sensor as a linear time-invariant response to the true concentration, plus noise: with \(e_t\) uncorrelated with \(y\) and with spectral density \(f_e\). A sensor that responds to fast changes less than to slow ones has \(|G(\nu)|\) decreasing in \(\nu\). Proof. Since \(e\) is uncorrelated with \(y\), Proposition 4 gives \(f_s = |G|^2 f_y + f_e\). Adding a constant does not change the spectrum, and multiplying by \(b\) multiplies it by \(b^2\). \(\square\) Adding covariates such as humidity or temperature to the regression adds their own (rescaled) spectra, but it does not change how the correction responds to \(y\) at each frequency. A regression with constant coefficients treats all time scales the same way, so it cannot undo a response that depends on frequency. The natural alternative is a correction that is itself a filter. Define the cross-spectrum \(f_{ys}(\nu) = \sum_h \operatorname{Cov}(y_{t+h}, s_t)\,e^{-2\pi i\nu h}\) and the coherence Proof. Let \(\varepsilon = y - \hat y\). By the computation in Proposition 4, \(\operatorname{Cov}(y_{t+h}, \hat y_t)\) has spectrum \(\overline{H}\,f_{ys}\), so
\[ f_\varepsilon = f_y - \overline{H} f_{ys} - H\,\overline{f_{ys}} + |H|^2 f_s = f_s\Big|H - \frac{f_{ys}}{f_s}\Big|^2 + f_y - \frac{|f_{ys}|^2}{f_s}. \]
The error \(\mathbb E\varepsilon_t^2 = \int f_\varepsilon\,d\nu\) is minimised frequency by frequency by making the first term zero, which leaves \(f_y(1-C)\). \(\square\) Coherence therefore has a direct meaning: \(C(\nu)\) is the fraction of the reference variance at frequency \(\nu\) that any linear correction of the sensor can recover. Where coherence is low, no calibration of this kind will help, and better hardware or more information is needed. A minimal Python version with In R, We used spectral analysis to compare hourly PM2.5 from PurpleAir low-cost sensors with EPA monitors in Cook County, Illinois, over October 2019 to September 2021. Corrected sensor data matched the reference over medium and long time scales, but not over the short term, where traffic-related variation appears. Both the standard US-wide correction and a local regression correction failed over the short term, and the corrected sensor data captured only a small fraction of the 8-hour peak. This is consistent with Proposition 6: a regression with constant coefficients cannot treat all time scales equally, which points toward frequency-based calibration. Details are in Kumar et al. (2023). \(\operatorname{Cov}(y_{t+h}, s_t) = \sum_j g_j\gamma_y(h+j)\), whose spectrum is \(\overline{G} f_y\), so \(f_{ys} = \overline G f_y\). By Proposition 4, \(f_s = |G|^2f_y + f_e\). Substituting gives both formulas. Coherence is a signal-to-noise ratio at each frequency: close to 1 where the sensor's response to \(y\) dominates its noise, and close to 0 where noise dominates. The Wiener filter inverts \(G\) where the signal is strong (\(H^\star\approx 1/G\) when \(f_e \ll |G|^2 f_y\)) and shrinks toward zero where it is weak, instead of amplifying noise. A pure sinusoid has Fourier coefficients only at \(n = \pm1\) in Lemma 5, so only the 24 h period appears. The second profile has coefficients at \(n=\pm1\) and \(n=\pm2\), so it peaks at 24 h and 12 h. Any daily profile that is not a pure sinusoid, such as one with two rush hours, contains such harmonics. A 12-hour peak alone therefore does not prove a separate 12-hour process; it may simply reflect the shape of the daily cycle. Each \(2I/f \sim \chi^2_2\), so \(2L\bar I/f \sim \chi^2_{2L}\). With \(2L = 16\), the 2.5% and 97.5% quantiles are 6.91 and 28.85, so a 95% interval is \(\big[16\bar I/28.85,\ 16\bar I/6.91\big] \approx [0.55\,\bar I,\ 2.32\,\bar I]\). Even after averaging eight values, the interval spans a factor of about four. This is why single periodogram peaks should be read with care.3. Filters and harmonics
4. Calibration in the frequency domain
5. Implementation
scipy.signal, for hourly series y (reference) and s (sensor) on the same timestamps. Tested on synthetic data: the periodogram integrates to the variance (Proposition 1), and white-noise ordinates have mean \(\sigma^2\) and variance \(\sigma^4\) (Proposition 3).import numpy as np
from scipy import signal
# periodogram (one-sided, frequencies in cycles per hour)
f, P = signal.periodogram(y - y.mean(), fs=1.0)
periods = 1 / f[1:] # hours
# averaged estimate (Welch, two-week segments) - consistent, lower variance
fw, Pw = signal.welch(y - y.mean(), fs=1.0, nperseg=24*14)
# coherence between sensor and reference, by period
fc, C = signal.coherence(s, y, fs=1.0, nperseg=24*14)
for p in [48, 24, 12, 8, 4]:
i = np.argmin(abs(1/fc[1:] - p))
print(f"coherence at {p} h: {C[1:][i]:.2f}")spec.pgram() computes smoothed periodograms and, for two series, their coherence.6. An application
Exercises
Show answer
Show answer
Show answer
References