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

D5 · Lesson 10 · Adaptive filters

Filters that tune their own taps to minimize an error, the least-mean-squares update and its step size, convergence speed against stability and excess noise, normalized LMS, and cancelling the echo in a speakerphone call

On a speakerphone call, the far talker's voice comes out of your loudspeaker, bounces around your room and goes back into your microphone, so they hear themselves a fraction of a second later. The echo path depends on the room, where you're sitting and who walks past, so no fixed filter can remove it. An adaptive filter learns it: it predicts the echo from the loudspeaker signal, subtracts the prediction from the microphone, and nudges its taps after every sample to make what's left smaller. The algorithm that does this, Widrow and Hoff's least-mean-squares rule from 1960, is three lines of code and runs in every phone.

  • The simplest case: an LMS filter with one weight learning an unknown gain from an input of power P. Each step multiplies the weight's error by (1−μP).
  • Small steps converge slowly and smoothly; steps with μP between 1 and 2 overshoot and alternate; above 2 the error grows and the filter diverges.
  • The readout gives the convergence time constant. Real filters with many taps trade this speed against the noise the fast updates leave behind.

Predict

An echo canceller samples at 8 kHz and must cover echoes up to 64 ms after the loudspeaker sound. How many taps does its adaptive filter need?

Name it

The LMS algorithm

An FIR filter with taps 𝐰 sees the recent inputs 𝐱n and produces yn=𝐰T𝐱n. With a desired signal dn (the microphone, in an echo canceller), the error is en=dn−yn and each step moves the taps downhill on the squared error:

𝐰n+1=𝐰n+μen𝐱n

Step size

For a single weight with input power P, the weight's error shrinks by (1−μP) each step, so it converges if 0<μ<2/P, with a time constant of −1/ln⁡|1−μP| steps. With N taps and white input, a safe bound is roughly μ<2/(NP), and smaller in practice. A larger μ converges faster but keeps jittering around the best taps, leaving an excess error, the misadjustment.

Normalized LMS

Dividing the step by the input's current energy, μ=μ~/(ϵ+𝐱nT𝐱n) with 0<μ~<2, makes the behavior independent of the signal's loudness, which matters for speech. For white input it converges with a time constant of about N/(μ~(2−μ~)) samples and leaves a misadjustment of about μ~/(2−μ~).

Echo cancellation

The loudspeaker signal is the filter's input, the microphone is d, and the error e is what's sent back to the far talker, with the echo removed. A double-talk detector freezes adaptation while the near talker speaks, so that their voice isn't mistaken for echo.

Worked example

The 512-tap canceller uses NLMS with μ~ = 0.5. How long does it take to converge, and what misadjustment does it leave?

Show the solution
  1. Convergence in samples. Nμ~(2−μ~)=5120.75=683samples
  2. In time. At 8 kHz: 6838000Hz=85ms Speech is far from white, so real convergence is slower.
  3. Misadjustment. μ~2−μ~=0.51.5=13 The leftover error power is a third more than the best possible.

Answer about 683 samples (85 ms) to converge, with a misadjustment of 1/3.

Worked example

A single-weight LMS has input power 0.25. What's the largest stable step, and what's the time constant at μP = 0.1?

Show the solution
  1. Largest stable step. μ<20.25=8
  2. Time constant. At μP = 0.1 the error shrinks by 0.9 per step: −1ln⁡0.9=9.5steps

Answer μ must stay below 8, and at μP = 0.1 the time constant is 9.5 steps.

Worked example

An echo canceller at 8 kHz must cover 64 ms of echo. How many taps does it need, and what does LMS cost per second?

Show the solution
  1. Taps. 0.064s×8000Hz=512
  2. Cost. LMS spends about two multiply-adds per tap per sample, one for the filter and one for the update: 2×512×8000=8.2×106per second
  3. In context. That's an easy load for a modern DSP but the reason early cancellers used shorter tails.

Answer 512 taps, and about 8.2 million multiply-adds a second.

Check

An echo canceller at 8 kHz must cover echoes up to 64 ms. How many taps does it need?

Check

A single-weight LMS filter has input power 0.5. What's the largest step size μ that still converges?

Check

A single-weight LMS has μP = 0.1. What's its convergence time constant in steps?

Check

A 512-tap NLMS filter at 16 kHz uses μ~ = 0.25. About how long does it take to converge on white input?

Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.

Check

An echo canceller at 8 kHz must cover 64 ms of echo tail.

(a)

How many taps does it need?

(b)

What does LMS cost, in millions of multiply-adds a second, at two per tap per sample?

Check

A single-weight LMS has input power 0.25 and step μ with μP = 0.05.

(a)

What is the largest stable step?

(b)

What is its time constant (the error shrinks by 1−2μP per step)?

Explain why

Why does a larger LMS step size make the filter converge faster but end up noisier?

Practice

Keep practicing

8 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.