Parametric spectra: linear prediction, Burg and MUSIC
| Problem | Estimate a spectrum by fitting a model, an autoregressive filter driven by white noise or a sum of sinusoids in noise, to resolve detail finer than the record’s DFT bins |
| Devised by | George Udny Yule (1927) and Gilbert Walker (1931), autoregressive models; Norman Levinson (1947) and James Durbin (1960), the fast recursion; John Burg (1967), maximum entropy spectra; Ralph Schmidt (1979, 1986), MUSIC |
| Accuracy | Levinson-Durbin agrees with SciPy’s solve_toeplitz to ; estimation accuracy depends on the model order and the data (tables below) |
| Cost | Levinson-Durbin after for the autocorrelation; Burg ; MUSIC for an covariance plus per frequency |
| Read first | Power spectra: periodogram, Welch, spectrogram and Lomb-Scargle, Linear least squares |
| API | autocorrelation, levinson_durbin, linear_predictive_coding, lpc_residual, lpc_synthesize, burg, ar_psd, maximum_entropy_spectrum, music, music_real, music_doa |
Overview
A periodogram assumes nothing about the signal and resolves no finer than one DFT bin, . If the signal is known to have structure, a model with a few parameters can be fitted and its spectrum computed exactly, at any resolution. Two models dominate:
- Autoregressive (AR): the signal is white noise passed through an all-pole filter, . Fitting the is linear prediction. The Levinson-Durbin recursion does it from the autocorrelation, and Burg’s method does it directly from the data. The fitted spectrum is smooth with sharp peaks, and Burg called it the maximum entropy spectrum.
- Sinusoids in white noise: the signal’s covariance matrix splits into a signal subspace and an orthogonal noise subspace. MUSIC finds the frequencies whose steering vectors are orthogonal to the noise subspace.
Both resolve tones far closer than a bin when the model fits. Both mislead when it doesn’t.
Where it is used
Parametric spectra can resolve peaks that a periodogram of a short record cannot.
- Speech coding. Linear prediction models the vocal tract; it is the basis of the speech coders used in mobile phones and voice-over-IP.
- Short data records. Burg’s method gives sharp spectra from a few hundred samples, as in geophysics, EEG and vibration analysis.
- Sinusoids in noise. MUSIC resolves closely spaced frequencies, in radar, sonar and spectroscopy.
History
George Udny Yule (1927) fitted an autoregression to sunspot numbers, and Gilbert Walker (1931) generalised it. Their normal equations bear both names. Norman Levinson (1947) solved Toeplitz systems in , and James Durbin (1960) adapted the method to autoregressions. Linear prediction became the core of speech coding (Bishnu Atal and Manfred Schroeder; Fumitada Itakura and Shuzo Saito, late 1960s). John Burg (1967), working on seismic data, proposed the maximum entropy method, which estimates the reflection coefficients from forward and backward prediction errors and always gives a stable model. Ralph Schmidt’s MUSIC (multiple signal classification, 1979, published 1986) introduced subspace methods for frequency and direction-of-arrival estimation.
The idea
Linear prediction and the Yule-Walker equations
The model. The periodogram assumes nothing about the signal, and pays for it with limited resolution. A parametric method assumes a model, fits its few parameters to the data, and computes the spectrum of the fitted model. The most useful model is autoregressive (AR): each sample is a linear combination of the previous samples plus a new random input ,
Equivalently, the signal is white noise passed through the all-pole filter , with . Poles near the unit circle give sharp peaks in the spectrum, so a low-order model can describe a resonant signal very compactly.
Fitting it. The coefficients are found by linear prediction: choose them so that predicts from its past with the smallest mean squared error. Setting the derivative of the error with respect to each coefficient to zero gives the Yule-Walker equations
where is the autocorrelation of the signal at lag , the average of . These are the normal equations of the prediction problem.
Solving them fast. The matrix of the system has entries that depend only on the difference of the indices: it is constant along each diagonal, a Toeplitz matrix. This structure allows a solution in operations instead of . The Levinson-Durbin recursion builds the predictor of order from the predictor of order , adding one new number at each stage:
Here is the prediction error power of the order- predictor, which can only decrease as the order grows. The reflection coefficients have magnitude below one exactly when the autocorrelation is positive definite, which guarantees a stable synthesis filter . They are also the coefficients of a lattice filter, a model of the vocal tract as a tube of uniform sections in speech coding. The prediction error power is the driving noise variance, and the AR spectrum is .
Burg’s method
The autocorrelation method uses the biased estimate , which implicitly pads the data with zeros and biases the fit. Burg’s method skips the autocorrelation. At each order it chooses the reflection coefficient that minimises the sum of the forward and backward prediction error powers,
then updates the errors and the predictor by Levinson’s step. By the Cauchy-Schwarz inequality , with strict inequality unless the signal is perfectly predictable, so the model is stable (a reflection coefficient of magnitude 1 would put a pole on the unit circle). For sharply resonant processes, Burg’s estimates are far better than the autocorrelation method’s:
Table 15.7. Autocorrelation and Burg estimates of a resonant AR(4) process.
| samples of a sharply resonant AR(4) process | Levinson-Durbin (autocorrelation method) error | Burg error |
|---|---|---|
| 64 | 4.167 | 0.172 |
| 256 | 3.412 | 0.065 |
| 1024 | 2.015 | 0.031 |
The process is Marple’s classic test case, , with poles at radius 0.98. The table shows the RMS error of the four coefficients, averaged over 50 records. The autocorrelation method’s zero-padding bias dominates even at 1024 samples.
Resolution beyond the periodogram
Two tones 0.015 cycles per sample apart, in 64 samples, are less than one bin apart ():
Figure 15.8. Parametric resolution.
The Hann periodogram shows a single broad hump. A Burg AR(16) model resolves two peaks, and MUSIC places sharp peaks almost exactly on the true frequencies: MUSIC’s two peaks: 0.1996 and 0.2153 cycles per sample (true 0.2000 and 0.2150).
MUSIC
MUSIC (multiple signal classification) is built for a narrower model: a few pure tones in white noise. It exploits the algebraic structure that this model gives to the covariance matrix of the data, and finds the frequencies from its eigenvectors.
Take vectors of consecutive samples. A complex exponential of frequency contributes to each such vector a multiple of the steering vector . With tones, the signal part of every data vector is a combination of only fixed vectors: it lies in a -dimensional signal subspace of the -dimensional space. The noise, by contrast, is spread equally over all dimensions. This shows in the covariance matrix. For complex exponentials in white noise, the covariance matrix of the data is , with steering vectors . The first term has rank and the second adds to every eigenvalue. So has large eigenvalues, whose eigenvectors span the signal subspace, and eigenvalues equal to , whose eigenvectors span the noise subspace. Eigenvectors of a Hermitian matrix belonging to different eigenvalues are orthogonal, so the noise subspace is orthogonal to the signal subspace, and in particular to the steering vector of every true frequency.
That gives a test for a candidate frequency : project its steering vector onto the noise subspace. If is one of the true frequencies the projection is zero; otherwise it is not. The MUSIC pseudospectrum is the reciprocal of the squared length of the projection,
which peaks sharply at the true frequencies. It is not a power spectrum: its height says nothing about power. A real sinusoid is two complex
exponentials, so music_real uses a signal subspace of dimension . The same pseudospectrum, with array steering vectors, estimates directions of arrival (music_doa).
The covariance eigenvalues confirm the model order: a gap after the -th (or -th) separates signal from noise.
Algorithm
Levinson-Durbin, from the autocorrelations .
- Set and start with no coefficients.
- For :
- compute the reflection coefficient ;
- if , the autocorrelation is not positive definite: stop with an error;
- update the coefficients: for (using the old values on the right), and ;
- update the error power: .
- Return the coefficients and the noise variance .
Cost: .
Burg’s method, from the samples themselves.
- Initialise the forward and backward prediction errors to the signal, .
- For each order :
- compute from the inner product of with delayed by one sample, and their energies;
- update the errors: and , both from the old values;
- update the coefficients and the error power by Levinson’s step.
Cost: .
The AR spectrum: for each requested frequency, evaluate the polynomial and return .
MUSIC, for exponentials and windows of samples.
- Slide a window of length along the signal and average the outer products of the windows with themselves to estimate the covariance matrix. Average it with its forward-backward mirror image, which uses each window a second time, reversed and conjugated.
- Compute the eigendecomposition; the eigenvectors of the smallest eigenvalues form .
- Evaluate the pseudospectrum on a grid of frequencies.
- Locate its highest peaks and refine each by fitting a parabola through the peak and its two neighbours.
Implementation
let mut a = vec![0.0; order + 1];
a[0] = 1.0;
let mut err = r[0];
let mut reflection = Vec::with_capacity(order);
for m in 1..=order {
let acc: f64 = (0..m).map(|k| a[k] * r[m - k]).sum();
let k = -acc / err;
if !k.is_finite() || k.abs() >= 1.0 + 1e-12 {
return Err(ErrorsJSL::RuntimeError("Autocorrelation sequence is not positive-definite"));
}
let prev = a.clone();
for i in 1..m {
a[i] = prev[i] + k * prev[m - i];
}
a[m] = k;
reflection.push(k);
err *= 1.0 - k * k;
}
let mut f = x.to_vec(); // forward prediction errors
let mut b = x.to_vec(); // backward prediction errors
let mut a = vec![1.0];
let mut reflection = Vec::with_capacity(order);
for m in 1..=order {
let (mut num, mut den) = (0.0, 0.0);
for i in m..n {
num += f[i] * b[i - 1];
den += f[i] * f[i] + b[i - 1] * b[i - 1];
}
let k = if den > 0.0 { -2.0 * num / den } else { 0.0 };
// Update the error sequences (iterate downwards so b[i-1] is still the old value).
for i in (m..n).rev() {
let (fi, bi) = (f[i], b[i - 1]);
f[i] = fi + k * bi;
b[i] = bi + k * fi;
}
let mut next = a.clone();
next.push(0.0);
for i in 1..=a.len() {
next[i] += k * a[a.len() - i];
}
a = next;
reflection.push(k);
variance *= 1.0 - k * k;
}
let (_, vectors) = hermitian_eigen(covariance)?;
let noise = vectors.slice(ndarray::s![.., num_sources..]).to_owned();
grid.iter()
.map(|&theta| {
let a = Array1::from(steering(theta));
if a.len() != m {
return Err(ErrorsJSL::IncompatibleArraySizes((a.len(), m)));
}
let proj: f64 = (0..noise.ncols()).map(|c| (0..m).map(|r| noise[(r, c)].conj() * a[r]).sum::<Complex<f64>>().norm_sqr()).sum();
Ok(1.0 / proj.max(f64::MIN_POSITIVE))
})
.collect()
levinson_durbinreturns ; SciPy’ssolve_toeplitzsolves for the predictor coefficients, which have the opposite sign.lpc_residualfilters by (the whitening, analysis filter);lpc_synthesizeby .
In practice
//! Parametric spectra: linear prediction, Burg's maximum entropy method and MUSIC.
use lib_jsl_dsp::discrete::spectral::linear_predictive_coding::{linear_predictive_coding, lpc_residual};
use lib_jsl_dsp::discrete::spectral::maximum_entropy::burg;
use lib_jsl_dsp::discrete::spectral::music::music_real;
use std::f64::consts::PI;
fn main() {
// An AR(2) resonance: x[n] = 1.6 x[n−1] − 0.9 x[n−2] + e[n].
let mut state = 7u64;
let mut noise = || {
state = state.wrapping_mul(6364136223846793005).wrapping_add(1442695040888963407);
(state >> 11) as f64 / (1u64 << 53) as f64 - 0.5
};
let mut x = vec![0.0; 2000];
for n in 2..x.len() {
x[n] = 1.6 * x[n - 1] - 0.9 * x[n - 2] + noise();
}
let lpc = linear_predictive_coding(&x, 2).unwrap();
let b = burg(&x, 2).unwrap();
println!("LPC A(z) = {:.4?}, reflection {:.4?}", lpc.coefficients, lpc.reflection);
println!("Burg A(z) = {:.4?}, noise variance {:.5} (true {:.5})", b.coefficients, b.variance, 1.0 / 12.0);
let e = lpc_residual(&x, &lpc.coefficients);
println!("prediction gain {:.1} dB", 10.0 * (x.iter().map(|v| v * v).sum::<f64>() / e.iter().map(|v| v * v).sum::<f64>()).log10());
// Three sinusoids in 100 samples.
let y: Vec<f64> = (0..100).map(|n| [0.1, 0.13, 0.31].iter().map(|f| (2.0 * PI * f * n as f64).sin()).sum::<f64>() + 0.05 * noise()).collect();
let m = music_real(&y, 3, 30, 4001, 1.0).unwrap();
println!("MUSIC peaks {:.4?}", m.peak_frequencies(3));
println!("largest covariance eigenvalues {:.2?}", &m.eigenvalues[..8]);
}
LPC A(z) = [1.0000, -1.5921, 0.8912], reflection [-0.8419, 0.8912]
Burg A(z) = [1.0000, -1.5934, 0.8921], noise variance 0.08145 (true 0.08333)
prediction gain 12.3 dB
MUSIC peaks [0.1000, 0.1300, 0.3100]
largest covariance eigenvalues [8.10, 7.89, 7.87, 7.55, 7.10, 6.32, 0.00, 0.00]
For a moderately resonant AR(2) process and 2000 samples, both fits are close to the true . MUSIC finds the three tones, and the eigenvalues fall off sharply after the sixth, the signal subspace of three real sinusoids.
Strengths
- Resolution beyond the DFT bin width from short records; smooth spectra with few parameters.
- Linear prediction is the basis of speech coding; MUSIC extends directly to sensor arrays.
Weaknesses
- The model order must be chosen: too low merges peaks, too high produces spurious ones.
- Model mismatch (coloured noise, non-sinusoidal signals) gives confidently wrong answers; MUSIC’s pseudospectrum carries no power information.
Exercises
- Derive the Yule-Walker equations from the orthogonality of the prediction error to the past samples.
- Show that , and deduce for a positive definite autocorrelation.
- Show that Burg’s reflection coefficient minimises the sum of forward and backward error powers, and that .
- Show that the steering vector of a true frequency is orthogonal to the noise subspace of .
- Fit AR models of orders 2 to 30 to the two-tone example and plot the spectra. Where do spurious peaks appear?
Hints and answers
- The error is orthogonal to for at the optimum. Taking expectations gives , the Yule-Walker equations.
- The Levinson update follows from the order update of the prediction error. For a positive definite autocorrelation, all so .
- Burg minimises over with , ; setting the derivative to zero gives , and by the Cauchy-Schwarz inequality , so .
- The signal subspace is spanned by the steering vectors of the true frequencies, and the noise subspace is its orthogonal complement.
- Spurious peaks appear when the order is too high relative to the data length, especially for noisy data; compare against the true tones’ positions.
Further reading
- S. L. Marple, Digital Spectral Analysis with Applications, Prentice Hall, 1987 (2nd ed., Dover, 2019).
- J. P. Burg, “Maximum entropy spectral analysis”, PhD thesis, Stanford University, 1975.
- R. O. Schmidt, “Multiple emitter location and signal parameter estimation”, IEEE Transactions on Antennas and Propagation 34 (1986) 276–280.
- J. Makhoul, “Linear prediction: a tutorial review”, Proceedings of the IEEE 63 (1975) 561–580.
- P. Stoica and R. Moses, Spectral Analysis of Signals, Prentice Hall, 2005.