Here 4096 samples of noise, made by a filter with four coefficients, are fitted one order at a time: each order predicts every sample from one more sample before it. Watch the error power left over: it falls until order 4, then stays near 1.
One order at a time
AR(4) noise (seed 253), 4096 samples: the estimated autocorrelation fed to the Levinson–Durbin recursion.
Order 0: no prediction; the error power is the whole power, 13.350.
Describe this picture
Two panels for AR(4) noise (seed 253), 4096 samples, whose estimated autocorrelation is fed to the Levinson–Durbin recursion. The first shows the reflection coefficients , from −1 to 1 against order from 1 to 8: the estimates are stems with square heads, and the true values, from the exact autocorrelation, open rings labelled “true”. The second shows the prediction-error power as bars, from 0 to 14 against order 0 to 8. A dotted level at 1 is labelled “σ_v² = 1 (measured 1.003)”: the driving noise’s nominal power and the mean square of the 4096 draws used. The readouts are the order , and . There is no control. Order 0 is one bar: no prediction, so the error power is the whole power, 13.350. Orders are then added one at a time, each with a stem and a bar. Orders 1 to 4 give = −0.711, 0.778, −0.358 and 0.736, beside the true rings, and the error power falls to 1.041. Orders 5 to 8 add coefficients no larger than 0.022, and the error power stays near 1 (1.040 at order 8): the data are AR(4).
A few numbers instead of a whole spectrum
In The periodogram (25.1), “More data, same scatter” showed the trouble with estimating a PSD bin by bin. Each bin scatters about the truth by about the truth itself, and more data only gives more bins.
But much of the noise we meet is white noise through a filter with a handful of coefficients. If I know that, I only need to estimate those few numbers. Then the filter hands me the whole spectrum, smooth, through 24.4’s rule.
Here is the model. An autoregressive model of order , AR() for short, makes each sample from the before it plus fresh white noise:
The number is the model order. The coefficients are the output-side coefficients of a difference equation, as in Difference equations (6.1), with . So is white noise , of variance , through the all-pole filter , where .
The AR(1) noise of “White noise forgets, coloured noise remembers” in Random processes (24.2), , is the case with . The minus sign is the difference-equation habit; this page keeps it.
What is its spectrum? In Power spectral density (24.4), “Memory in time, narrowness in frequency” gave two facts. White noise has a flat PSD, , and a filter multiplies a PSD by . Here , so
Every pole pair of near the unit circle makes a peak at its angle, as “Where the pair sits is how h[n] moves” showed in Transfer functions, poles & zeros (16.3). A pair takes two coefficients, so numbers can draw up to such peaks.
There are two other models. A moving-average model, MA, is white noise through an FIR filter: , with zeros instead of poles. An ARMA model has both, and its PSD is . This page fits AR models, because their coefficients come from linear equations.
Predict the next sample
How do I find the from data? Turn the model round. If is made from its past plus something new, I can guess it from its past. The prediction from the samples before is
and the prediction error is what is left:
That is through the FIR filter . If really is AR() with these , the error is exactly : the part nobody could have guessed.
I choose the that make the mean square of the error as small as possible. As in “Least squares or least worst” in Optimal FIR design (19.3), the error is linear in the coefficients, so its mean square is a quadratic. Its lowest point comes from linear equations.
Here is a way to see those equations without calculus. Suppose the error were still correlated with one of the past samples, say . Then I could add a little more of to the prediction and shrink the error. So at the best coefficients the error is uncorrelated with each of the past samples:
Averages add (24.2), and each product averages to an autocorrelation: and . So for ,
These are the Yule–Walker equations. For they read
where I used from 24.2. In general they are . The matrix has in row , column ; holds to , and holds to .
Look at the matrix. Every diagonal holds one value: on the main one, beside it, and so on. A matrix that is constant along each diagonal is called Toeplitz.
The error power left at the best coefficients is worth knowing too. The error is uncorrelated with the past samples, so its mean square equals the mean of the error times alone:
With data, I replace each by an estimate from samples. 24.2 divided the products at lag by their number. Here I divide by :
The reason is stability. With , is positive definite: every weighted sum of samples gets a positive power from it, as a real power must. That keeps the error powers of the next section positive, and the fitted model stable. Dividing by does not promise it.
Solving it one order at a time
Elimination solves equations in about steps. The Levinson–Durbin recursion uses the Toeplitz pattern to do it in about . It solves the order-1 problem, then grows the answer to order 2, 3, and on up to .
It starts from no prediction at all, with error power , the whole power. Going from order to order takes three lines. First the reflection coefficient
Then the new coefficients, for , all computed from the old ones at once, and one more:
Then the new error power:
The top of has a meaning. It is the average of the order- error times , the one sample the shorter predictor did not use. If the error has nothing in common with it, , the coefficients stay as they were, and so does the error power.
The name comes from Filter structures (21.1). In “Three more ways to build it”, the lattice of had and . That is this recursion at order 2. It sets and turns into , so 21.1’s formulas are the recursion read from the ‘s back to the ‘s.
21.1 also showed that the biquad’s stability triangle of Stability and causality (16.4), “The triangle is the inside of the circle”, is and . The rule holds at every order: is stable when every . A positive definite keeps every positive, and then forces each .
Try it on 24.2’s AR(1) noise with , scaled to variance 1, so . Order 1 gives and , the driving noise’s power. Order 2 gives . The second sample back adds nothing, because the noise is AR(1).
The picture at the top of the page runs the recursion on a known AR(4) process. Its poles are two pairs, at angles and at , and . Multiplying out the two biquads gives the coefficients = 1, −1.8187, 2.1453, −1.4992, 0.7310. Its true PSD has peaks at 0.20π and 0.44π. The second peak sits a little below its pole angle, because it rides on the downward slope of the first.
One order at a time
That picture feeds the estimates to of 4096 samples to the recursion, and shows each order as it is added: a stem for and a bar for . Its dotted level marks the driving noise’s power, 1, which measures 1.003 for the draws used.
Watch the bars. Each order shrinks the error power, from 13.350 to 1.041 at order 4. Then it stops: from order 4 on, stays between 1.040 and 1.041, close to the driving noise’s power. Past the true order the new are close to 0, the “nothing in common” case.
Notice also that order 3 helps little, from 2.607 to 2.273, and order 4 a lot. So look for where the error power stops falling for good, not for its first pause.
The estimated order-4 model is = 1, −1.8052, 2.1355, −1.4928, 0.7362, against the true 1, −1.8187, 2.1453, −1.4992, 0.7310. SciPy’s solve_toeplitz, which solves directly, gives the same numbers to about , which is rounding error.
Every is at most 0.778, so the model is stable: 16.4’s triangle, at order 4. Its poles are 0.952 at and 0.902 at , close to the true 0.95 at and 0.9 at .
A smooth model against a ragged periodogram
Now the payoff: the spectrum. Once I have the of order , the AR estimate of the PSD is the model’s PSD, with the final error power standing in for :
Here is the order- polynomial, and the hat means “estimated”, as in 24.1. The next instrument draws it against the periodogram of 25.1, , from the same samples: the first 1024 samples of the record in “One order at a time”, with the fit made from their own autocorrelation.
A peak here is a local maximum that stands at least 2 dB above its surroundings. The distance from the truth is the RMS, over Ω from 0 to π, of the difference in dB between the AR estimate and the true PSD.
A smooth model against a ragged periodogram
1024 samples of the AR(4) noise: the periodogram, the AR(p) estimate and the true PSD.
Order 2: one smooth peak, at 0.26π, where the truth has two (0.20π, 0.44π); distance from the truth 7.2 dB. The periodogram's dots scatter widely about the truth.
Describe this picture
One panel for 1024 samples of the AR(4) noise: PSD in dB from −30 to 30 against Ω from 0 to π rad/sample. The periodogram is small dots, and a value below −30 dB is drawn on the floor as a small open triangle. The AR() estimate is a solid curve with small filled diamonds at its peaks, and the true PSD is dashed. A key names them “periodogram”, “AR estimate”, “peak” and “true PSD”. The readouts are the order , where the peaks are and the distance from the truth. At order 2 there is one smooth peak, at 0.26π, where the truth has two (0.20π, 0.44π), 7.2 dB from the truth; the periodogram’s dots scatter widely about it. At order 4, the true order, the peaks are at 0.20π and 0.45π, 1.3 dB away. At order 20 the same two peaks sit at 0.21π and 0.45π, with a bump near 0.93π (1.4 dB) that the truth does not have, 1.6 dB away. When the clip ends, a slider “Order p”, named “AR order p”, sets the order from 1 to 20. At other orders the caption reads in the form “Order 8: peaks at 0.20π, 0.45π, distance 1.5 dB.”
Watch the solid curve as the order goes from 2 to 4 to 20: one peak between the true two, then both, then both with a bump the truth does not have. More order is not better.
When the clip ends, use the slider to try a few orders. At order 1 there is no peak at all, and the distance is 12.1 dB. Order 3 still finds one peak, at 0.30π, 6.0 dB away. From order 4 the two peaks are there: orders 8 and 12 sit 1.5 dB away and order 16 1.6 dB, a little worse than order 4’s 1.3 dB.
So too low an order merges the two peaks into one, between them. The right order finds both. A much higher order still finds them, but spends its spare coefficients on small bumps the truth does not have.
The periodogram of the same 1024 samples is 6.1 dB away from the truth, worse than any AR estimate from order 4 to 20. Its dots carry no assumption about the shape, and they pay for it in scatter. The AR curve assumes a few poles, and gains a smooth line when that assumption is right.
How do I choose the order with real data, where there is no truth to compare with? I look where the error power of “One order at a time” stops falling. Criteria such as Akaike’s AIC make this a rule: they add a penalty for each coefficient to the logarithm of the error power, and pick the order where the sum is smallest.
The AR estimate needs enough data too, because it is built from estimated correlations. With only the first 256 samples, the order-4 fit’s second peak, near 0.44π, stands just 0.5 dB above its surroundings.
The maths behind it · the partial autocorrelation
In statistics, the AR() model and its partial autocorrelation function, PACF, are these. The PACF at lag is , and for an AR() process it is 0 after lag . An estimate beyond the true order scatters by about , which is 0.016 for clip 1’s 4096 samples: the largest there, 0.022, is 1.4 times that.
Worked example
1. Levinson by hand, two orders. Take , , . Order 1: , and .
Order 2: , which is , and . The new , and .
Check both Yule–Walker equations: and . The error power checks too: .
2. The clip’s data. In “One order at a time” the error power falls from 13.350 to 1.041 at order 4 and then stays flat, 1.041 and 1.040. That is near the driving noise’s measured power, 1.003, so the order is 4.
Where you’ll meet this
Speech is the classic case. A voice is a buzz or a hiss shaped by the throat and mouth, and over a short frame that shaping is close to an all-pole filter. Speech coders at 8 kHz fit an AR model of order 8 to 10 to each frame of 10 to 25 ms, and send its coefficients instead of the samples. The source–filter model of speech (30.1) builds this.
Some coders send the reflection coefficients, or numbers made from them. A is easy to keep inside after rounding, so the decoded filter stays stable.
AR estimates also suit short records, where a periodogram cannot separate close peaks. High-resolution frequency estimation (25.4) takes that further. The same Toeplitz system, with a cross-correlation on the right, returns as the Wiener–Hopf equations of The Wiener filter (26.2).
For more, see J. Makhoul, “Linear prediction: a tutorial review” (Proc. IEEE, 1975); J. G. Proakis and D. G. Manolakis, Digital Signal Processing, ch. 12 and 14; and P. Stoica and R. Moses, Spectral Analysis of Signals (2005), ch. 3. In SciPy, solve_toeplitz(r[:p], -r[1:p+1]) solves Yule–Walker, with r holding the estimates to .
The maths behind it · symmetric Toeplitz systems
Yule–Walker is a symmetric Toeplitz system, and Levinson–Durbin solves it in about steps instead of by using that structure. The error powers are the pivots of the factorisation, the Cholesky factorisation without square roots, of the autocorrelation matrix.
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| AR() | PSD | |
| MA, ARMA | , | PSD |
| Prediction | error is through | |
| Yule–Walker | , | , Toeplitz |
| Levinson–Durbin | , | ; about steps |
| Stability | all | lattice of 21.1 |
| AR estimate | biased correlations | |
| Order | where stops falling | AIC formalises it |