S735 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

S7 · Lesson 35 · Spectral analysis lab

Window figures of merit, scalloping by direct evaluation, and Levinson–Durbin on a known AR process, in Python

Lessons 29 to 34 quoted tables: a Hann window's coherent gain of 0.5 and noise bandwidth of 1.5 bins, scalloping losses of 3.92 and 1.42 dB, and the claim that Levinson–Durbin recovers an AR model's coefficients from its autocorrelation. This lab computes each from its definition: the window figures from the samples themselves, the scalloping loss by evaluating the window's transform half a bin off, and an AR(2) model recovered exactly from the autocorrelation the Yule–Walker equations predict.

  • The curve is the peak response of an N-point DFT to a tone d bins away from the nearest bin, for a rectangular window: |sin⁡πdNsin⁡(πd/N)| in dB, with N = 64.
  • It is 0 dB on a bin and drops to −3.92 dB halfway between bins (the right edge): the scalloping loss. Past halfway the tone is nearer the next bin, so the picture repeats.
  • A Hann window's wider main lobe flattens this to −1.42 dB, at the cost of 1.76 dB more noise bandwidth.

Predict

An AR(2) process has a₁ = 0.75, a₂ = −0.5 and unit driving noise. Its autocorrelation is computed exactly and fed to Levinson–Durbin with order 2. What comes out?

Name it

What the lab computes

  • Windows (periodic forms): rectangular; Hann 0.5−0.5cos⁡(2πn/N); Hamming 0.54−0.46cos⁡(2πn/N).
  • Coherent gain 1N∑w and ENBW N∑w2(∑w)2 bins.
  • Scalloping loss: 20log10⁡|W(π/N)||W(0)|, the window's transform half a bin from its peak, by direct summation.
  • Levinson–Durbin: from φ[0..p], the reflection coefficients and predictor coefficients order by order, with Ei=Ei−1(1−ki2) (lesson 34).

Check

Write window(name, N) for 'rect', 'hann' and 'hamming' (periodic forms), and cg(w) and enbw(w).

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Write scalloping_db(w): the window's response half a bin off, relative to its peak, in dB, by direct evaluation of its DTFT.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Write levinson(phi, p): return (a, E) with a = [a₁, …, a_p] the predictor coefficients and E the final prediction error.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Explain why

Why does a window with lower scalloping loss usually have a larger noise bandwidth?