3 min read
On this page

Spectral Analysis

Spectral analysis estimates the frequency content of signals, going beyond the basic DFT to handle noise, finite data, and statistical estimation.

Power Spectral Density (PSD)

The PSD S(f) describes how a signal's power is distributed across frequencies.

For a stationary random process: S(f) = FT{R(τ)} where R(τ) is the autocorrelation function (Wiener-Khintchine theorem).

Non-Parametric Methods

Periodogram

The simplest PSD estimator: squared magnitude of the DFT.

P(k) = (1/N) |X[k]|² = (1/N) |Σ x[n]e^(-j2πkn/N)|²

Problem: High variance — the periodogram is a noisy estimate of the true PSD. Variance doesn't decrease with more data (inconsistent estimator).

Welch's Method

Reduce variance by averaging periodograms of overlapping segments.

  1. Divide signal into L overlapping segments (50-75% overlap typical).
  2. Window each segment.
  3. Compute periodogram of each segment.
  4. Average the periodograms.
S_welch(k) = (1/L) Σₗ |X_l[k]|²

Variance reduction: Proportional to 1/L. More segments → smoother estimate. But shorter segments → worse frequency resolution.

The standard method for practical spectral estimation. Used in scipy.signal.welch, MATLAB pwelch.

Bartlett's Method

Like Welch but with non-overlapping segments and no windowing. Simpler but less efficient (less variance reduction per data sample).

Multitaper Method

Use multiple orthogonal windows (Slepian/DPSS tapers) on the same data. Average the resulting periodograms.

Advantages: Better bias-variance tradeoff than Welch. Uses all data (no segmentation). Optimal for stationary signals.

Thomson's method: Choose K tapers with time-bandwidth product NW. K ≈ 2NW - 1 independent estimates.

Parametric Methods

Model the signal generation process and estimate model parameters. Often more accurate than non-parametric methods for short data records.

AR (Autoregressive) Model

x[n] = -Σₖ₌₁ᵖ aₖx[n-k] + e[n]    (e[n] = white noise)

The signal is modeled as the output of an all-pole filter driven by white noise.

PSD: S(f) = σ²/|1 + Σ aₖ e^(-j2πfk)|² — smooth, with peaks at resonant frequencies.

Yule-Walker equations: Solve for AR coefficients from the autocorrelation.

Burg's method: Estimate AR coefficients by minimizing forward and backward prediction error simultaneously. Better for short data, no windowing artifacts.

Model order selection: AIC (Akaike Information Criterion) or MDL (Minimum Description Length) balance model fit vs complexity.

MA (Moving Average) Model

x[n] = Σₖ₌₀ᵍ bₖe[n-k]

All-zero model. PSD has dips (zeros) at specific frequencies.

ARMA Model

Combined AR + MA. Most general linear model. More flexible but harder to estimate.

Cross-Spectral Analysis

Cross-Spectral Density

S_xy(f) = FT{R_xy(τ)}    where R_xy(τ) = E[x(t)y*(t-τ)]

Measures the frequency-domain relationship between two signals.

Coherence

γ²_xy(f) = |S_xy(f)|² / (S_xx(f) · S_yy(f))

γ² ∈ [0, 1]. Measures the linear correlation between two signals at each frequency.

γ² = 1: Perfectly linearly related at this frequency. γ² = 0: Uncorrelated at this frequency.

Applications: System identification (input-output coherence), noise source identification, EEG connectivity analysis.

Cepstral Analysis

The cepstrum is the inverse DFT of the log magnitude spectrum:

c[n] = IDFT{log|X[k]|}

Applications: Pitch detection (fundamental frequency appears as a peak in the cepstrum). Speech analysis (separate vocal tract from excitation). Echo detection.

MFCCs (Mel-Frequency Cepstral Coefficients): Apply mel-scale filterbank → log → DCT → keep first 12-13 coefficients. The standard audio feature for speech recognition.

Applications in CS

  • Audio/speech: Pitch detection, formant analysis, MFCCs for speech recognition, music analysis.
  • Vibration analysis: Detect machine faults from vibration spectra.
  • Radar/sonar: Target detection, Doppler analysis, range estimation.
  • Biomedical: EEG spectral analysis (alpha, beta, theta bands), heart rate variability (HRV).
  • Network monitoring: Traffic spectrum analysis, anomaly detection.