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

S7 · Lesson 38 · Recursive least squares

Exponentially weighted least squares, the RLS recursion, forgetting, tracking and cost

LMS (lesson 37) takes one cheap gradient step per sample, and with a strongly colored input its slow eigenmodes take thousands of samples to settle. Recursive least squares instead solves the full least-squares problem for all the data so far, updating the solution with each new sample at a cost of order P² instead of P. It converges in about twice the filter length whatever the input's spectrum, and a forgetting factor lets it track a changing system. Echo cancellers, channel equalizers and adaptive arrays that must converge fast use it or its fast variants.

  • The curve is RLS's steady-state misadjustment against the forgetting factor λ, for P taps: about P(1−λ)1+λ.
  • λ close to 1 means a long memory, 1/(1−λ) samples, and little excess error; smaller λ forgets faster, tracks changes faster, and is noisier.
  • With 10 taps and λ = 0.99 the misadjustment is 5%, from a memory of 100 samples.

Predict

A 4-tap system is identified from 200 samples of a strongly colored input (white noise through a pole at 0.9), with no measurement noise. How do LMS (μ = 0.01) and RLS compare?

Name it

The cost and its solution

RLS minimizes the exponentially weighted error

J[n]=∑i=0nλn−i(d[i]−𝐰T𝐱[i])2

with forgetting factor 0 < λ ≤ 1 (memory about 1/(1−λ) samples). Its solution is 𝐰=Φ−1𝐳 with Φ=∑λn−i𝐱𝐱T and 𝐳=∑λn−id𝐱.

The recursion

Keeping 𝐏=Φ−1 and updating it by the matrix inversion lemma, each sample costs O(P²):

𝐤=𝐏𝐱λ+𝐱T𝐏𝐱,e=d−𝐰T𝐱,𝐰←𝐰+𝐤e,𝐏←𝐏−𝐤𝐱T𝐏λ

started from w = 0 and 𝐏=δ−1I with δ small.

Behavior

  • Convergence in about 2P samples, independent of the eigenvalue spread.
  • Misadjustment for a fixed system, M≈P(1−λ)1+λ; with λ = 1 it goes to zero as the data accumulate (it becomes ordinary least squares).
  • Tracking: smaller λ follows a changing system faster at the cost of more misadjustment, the same trade as LMS's step size.
  • Cost and numerics: O(P²) per sample against LMS's O(P); in finite precision P can lose symmetry and positive definiteness, so robust versions use square-root (QR) forms, and fast transversal or lattice versions bring the cost to O(P) for tapped-delay-line inputs.

Worked example

An RLS filter has 10 taps and λ = 0.99. What memory and misadjustment does it have? What λ gives a memory of 1000 samples?

Show the solution
  1. Memory. L=11−0.99=100samples
  2. Misadjustment. M=10×0.011.99=5.0%
  3. For a 1000-sample memory. λ=1−1/1000=0.999 with misadjustment 0.5%.
  4. The trade. Tenfold memory gives tenfold lower excess error and tenfold slower tracking.

Answer a memory of 100 samples and 5.0% misadjustment; λ = 0.999 gives a memory of 1000 samples.

Worked example

A one-tap RLS filter with x = 1 every sample, λ = 1 and a huge initial P sees d = 2, 4, 3. What does its weight become?

Show the solution
  1. What the weight is. With x = 1 the least-squares weight is just the average of the d values so far.
  2. Step by step. That's 2 after one sample, 3 after two and 3 after three.
  3. Why. RLS with λ = 1 reproduces ordinary least squares exactly at every step; with λ < 1 it would be an exponentially weighted average instead.

Answer the weight goes 2, 3, 3, ending at 3.

Worked example

A 64-tap echo canceller could use LMS or RLS. Roughly how do their costs per sample compare, and what does RLS buy?

Show the solution
  1. LMS cost. About 2P = 128 multiplications per sample.
  2. RLS cost. Standard RLS costs on the order of P2, here a few thousand.
  3. What RLS buys. It converges in about 2P = 128 samples regardless of the speech's spectrum, where LMS on colored speech may take tens of thousands.
  4. Fast RLS. Fast RLS variants exploit the delay-line structure to get RLS's convergence at roughly ten times LMS's cost.

Answer LMS costs about 128 multiplications per sample and RLS a few thousand; RLS buys convergence in about 128 samples whatever the input's spectrum.

Check

An RLS filter has 16 taps and forgetting factor 0.95.

(a)

What is its memory?

(b)

What misadjustment does it have?

Check

An 8-tap RLS filter should remember about 200 samples.

(a)

What forgetting factor does it use?

(b)

What misadjustment results?

Check

A one-tap RLS filter with x = 1, λ = 1 and a huge initial P receives d = 2, 4, 10.

(a)

What is its weight after two samples?

(b)

After three?

Check

A 32-tap adaptive filter runs at 8 kHz.

(a)

Roughly how long does RLS take to converge?

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

(b)

By roughly what factor does RLS's per-sample cost exceed LMS's (P² against P)?

Check

A channel equalizer must converge within a short training sequence, and the channel's frequency response has deep notches. Why does RLS suit it better than LMS?

Check

An RLS filter has P taps and forgetting factor l.

Step 1

What is its memory in samples?

Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.

Check

Write rls(x, d, P, lam=1.0, delta=1e-4): run RLS for a P-tap filter on input x and desired d (lists), starting from w = 0 and P = I/δ, and return the final weights.

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 RLS converge in about twice the filter length regardless of the input's spectrum, while LMS can take far longer?

Practice

Keep practicing

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