Recursive least squares filter explained

Recursive least squares (RLS) is an adaptive filter algorithm that recursively finds the coefficients that minimize a weighted linear least squares cost function relating to the input signals. This approach is in contrast to other algorithms such as the least mean squares (LMS) that aim to reduce the mean square error. In the derivation of the RLS, the input signals are considered deterministic, while for the LMS and similar algorithms they are considered stochastic. Compared to most of its competitors, the RLS exhibits extremely fast convergence. However, this benefit comes at the cost of high computational complexity.

Motivation

RLS was discovered by Gauss but lay unused or ignored until 1950 when Plackett rediscovered the original work of Gauss from 1821. In general, the RLS can be used to solve any problem that can be solved by adaptive filters. For example, suppose that a signal

d(n)

is transmitted over an echoey, noisy channel that causes it to be received as
q
x(n)=\sum
k=0

bn(k)d(n-k)+v(n)

where

v(n)

represents additive noise. The intent of the RLS filter is to recover the desired signal

d(n)

by use of a

p+1

-tap FIR filter,

w

:

d(n)

p
\sum
k=0

w(k)x(n-k)=wTxn

where

xn=[x(n)x(n-1)\ldotsx(n-p)]T

is the column vector containing the

p+1

most recent samples of

x(n)

. The estimate of the recovered desired signal is

\hat{d}(n)=

p
\sum
k=0

wn(k)x(n-k)=w

T
n

xn

The goal is to estimate the parameters of the filter

w

, and at each time

n

we refer to the current estimate as

wn

and the adapted least-squares estimate by

wn+1

.

wn

is also a column vector, as shown below, and the transpose,
T
w
n
, is a row vector. The matrix product
T
w
n

xn

(which is the dot product of

wn

and

xn

) is

\hat{d}(n)

, a scalar. The estimate is "good" if

\hat{d}(n)-d(n)

is small in magnitude in some least squares sense.

As time evolves, it is desired to avoid completely redoing the least squares algorithm to find the new estimate for

wn+1

, in terms of

wn

.

The benefit of the RLS algorithm is that there is no need to invert matrices, thereby saving computational cost. Another advantage is that it provides intuition behind such results as the Kalman filter.

Discussion

C

by appropriately selecting the filter coefficients

wn

, updating the filter as new data arrives. The error signal

e(n)

and desired signal

d(n)

are defined in the negative feedback diagram below:

The error implicitly depends on the filter coefficients through the estimate

\hat{d}(n)

:

e(n)=d(n)-\hat{d}(n)

The weighted least squares error function

C

—the cost function we desire to minimize—being a function of

e(n)

is therefore also dependent on the filter coefficients:

C(wn)=\sum

nλ
i=0

n-ie2(i)

where

0<λ\le1

is the "forgetting factor" which gives exponentially less weight to older error samples.

The cost function is minimized by taking the partial derivatives for all entries

k

of the coefficient vector

wn

and setting the results to zero
\partialC(wn)
\partialwn(k)
n
=\sum
i=0

n-ie(i)

\partiale(i)
\partialwn(k)
n
=-\sum
i=0

n-ie(i)x(i-k)=0    k=0,1,\ldots,p

Next, replace

e(n)

with the definition of the error signal
nλ
\sum
i=0

n-i

p
\left[d(i)-\sum
\ell=0

wn(\ell)x(i-\ell)\right]x(i-k)=0    k=0,1,\ldots,p

Rearranging the equation yields
p
\sum
\ell=0

wn(\ell)\left[\sum

n
i=0

λn-ix(i-\ell)x(i-k)\right]=

n
\sum
i=0

λn-id(i)x(i-k)    k=0,1,\ldots,p

This form can be expressed in terms of matrices

Rx(n)wn=rdx(n)

where

Rx(n)

is the weighted sample covariance matrix for

x(n)

, and

rdx(n)

is the equivalent estimate for the cross-covariance between

d(n)

and

x(n)

. Based on this expression we find the coefficients which minimize the cost function as

wn

-1
=R
x

(n)rdx(n)

This is the main result of the discussion.

Choosing λ

The smaller

λ

is, the smaller is the contribution of previous samples to the covariance matrix. This makes the filter more sensitive to recent samples, which means more fluctuations in the filter co-efficients. The

λ=1

case is referred to as the growing window RLS algorithm. In practice,

λ

is usually chosen between 0.98 and 1.[1] By using type-II maximum likelihood estimation the optimal

λ

can be estimated from a set of data.[2]

Recursive algorithm

The discussion resulted in a single equation to determine a coefficient vector which minimizes the cost function. In this section we want to derive a recursive solution of the form

wn=wn-1+\Deltawn-1

where

\Deltawn-1

is a correction factor at time

{n-1}

. We start the derivation of the recursive algorithm by expressing the cross covariance

rdx(n)

in terms of

rdx(n-1)

rdx(n)

n
=\sum
i=0

λn-id(i)x(i)

n-1
=\sum
i=0

λn-id(i)x(i)0d(n)x(n)

rdx(n-1)+d(n)x(n)

where

x(i)

is the

{p+1}

dimensional data vector

x(i)=[x(i),x(i-1),...,x(i-p)]T

Similarly we express

Rx(n)

in terms of

Rx(n-1)

by

Rx(n)

n
=\sum
i=0

λn-ix(i)xT(i)

Rx(n-1)+x(n)xT(n)

In order to generate the coefficient vector we are interested in the inverse of the deterministic auto-covariance matrix. For that task the Woodbury matrix identity comes in handy. With

A

Rx(n-1)

is

(p+1)

-by-

(p+1)

U

=x(n)

is

(p+1)

-by-1 (column vector)

V

=xT(n)

is 1-by-

(p+1)

(row vector)

C

=I1

is the 1-by-1 identity matrix
The Woodbury matrix identity follows
-1
R
x

(n)

=

\left[λRx(n-1)+x(n)xT(n)\right]-1

=

-1
\dfrac{1}{λ}\left\lbraceR
x
-1
(n-1)-\dfrac{R
x

(n-1)x(n)xT

-1
(n)R
x

(n-1)}{λ+xT

-1
(n)R
x

(n-1)x(n)}\right\rbrace

To come in line with the standard literature, we define

P(n)

-1
=R
x

(n)

-1P(n-1)-g(n)xT(n)λ-1P(n-1)

where the gain vector

g(n)

is

g(n)

-1P(n-1)x(n)\left\{1+xT(n)λ-1P(n-1)x(n)\right\}-1

=P(n-1)x(n)\left\{λ+xT(n)P(n-1)x(n)\right\}-1

Before we move on, it is necessary to bring

g(n)

into another form

g(n)\left\{1+xT(n)λ-1P(n-1)x(n)\right\}

-1P(n-1)x(n)

g(n)+g(n)xT(n)λ-1P(n-1)x(n)

-1P(n-1)x(n)

Subtracting the second term on the left side yields

g(n)

-1P(n-1)x(n)-g(n)xT(n)λ-1P(n-1)x(n)

-1\left[P(n-1)-g(n)xT(n)P(n-1)\right]x(n)

With the recursive definition of

P(n)

the desired form follows

g(n)=P(n)x(n)

Now we are ready to complete the recursion. As discussed

wn

=P(n)rdx(n)

P(n)rdx(n-1)+d(n)P(n)x(n)

The second step follows from the recursive definition of

rdx(n)

. Next we incorporate the recursive definition of

P(n)

together with the alternate form of

g(n)

and get

wn

\left[λ-1P(n-1)-g(n)xT(n)λ-1P(n-1)\right]rdx(n-1)+d(n)g(n)

=P(n-1)rdx(n-1)-g(n)xT(n)P(n-1)rdx(n-1)+d(n)g(n)

=P(n-1)rdx(n-1)+g(n)\left[d(n)-xT(n)P(n-1)rdx(n-1)\right]

With

wn-1=P(n-1)rdx(n-1)

we arrive at the update equation

wn

=wn-1+g(n)\left[d(n)-xT(n)wn-1\right]

=wn-1+g(n)\alpha(n)

where

\alpha(n)=d(n)-xT(n)wn-1

is the a priori error. Compare this with the a posteriori error; the error calculated after the filter is updated:

e(n)=d(n)-xT(n)wn

That means we found the correction factor

\Deltawn-1=g(n)\alpha(n)

This intuitively satisfying result indicates that the correction factor is directly proportional to both the error and the gain vector, which controls how much sensitivity is desired, through the weighting factor,

λ

.

RLS algorithm summary

The RLS algorithm for a p-th order RLS filter can be summarized as

Parameters:

p=

filter order

λ=

forgetting factor

\delta=

value to initialize

P(0)

Initialization:

w(0)=0

,

x(k)=0,k=-p,...,-1

,

d(k)=0,k=-p,...,-1

P(0)=\deltaI

where

I

is the identity matrix of rank

p+1

Computation: For

n=1,2,...

x(n)=\left[ \begin{matrix} x(n)\\ x(n-1)\\ \vdots\\ x(n-p) \end{matrix} \right]

\alpha(n)=d(n)-xT(n)w(n-1)

g(n)=P(n-1)x(n)\left\{λ+xT(n)P(n-1)x(n)\right\}-1

P(n)-1P(n-1)-g(n)xT(n)λ-1P(n-1)

w(n)=w(n-1)+\alpha(n)g(n)

.

The recursion for

P

follows an algebraic Riccati equation and thus draws parallels to the Kalman filter.[3]

Lattice recursive least squares filter (LRLS)

The lattice recursive least squares adaptive filter is related to the standard RLS except that it requires fewer arithmetic operations (order N).[4] It offers additional advantages over conventional LMS algorithms such as faster convergence rates, modular structure, and insensitivity to variations in eigenvalue spread of the input correlation matrix. The LRLS algorithm described is based on a posteriori errors and includes the normalized form. The derivation is similar to the standard RLS algorithm and is based on the definition of

d(k)

. In the forward prediction case, we have

d(k)=x(k)

with the input signal

x(k-1)

as the most up to date sample. The backward prediction case is

d(k)=x(k-i-1)

, where i is the index of the sample in the past we want to predict, and the input signal

x(k)

is the most recent sample.[5]

Parameter summary

\kappaf(k,i)

is the forward reflection coefficient

\kappab(k,i)

is the backward reflection coefficient

ef(k,i)

represents the instantaneous a posteriori forward prediction error

eb(k,i)

represents the instantaneous a posteriori backward prediction error
d
\xi
bmin

(k,i)

is the minimum least-squares backward prediction error
d
\xi
fmin

(k,i)

is the minimum least-squares forward prediction error

\gamma(k,i)

is a conversion factor between a priori and a posteriori errors

vi(k)

are the feedforward multiplier coefficients.

\varepsilon

is a small positive constant that can be 0.01

LRLS algorithm summary

The algorithm for a LRLS filter can be summarized as

Initialization:
For i = 0,1,\ldots,N

\delta(-1,i)=\deltaD(-1,i)=0

(if x(k) = 0 for k < 0)
d
\xi
bmin

(-1,i)=

d
\xi
fmin

(-1,i)=\varepsilon

\gamma(-1,i)=1

eb(-1,i)=0

End
Computation:
For k \ge 0

\gamma(k,0)=1

eb(k,0)=ef(k,0)=x(k)

d
\xi
bmin

(k,0)=

d
\xi
fmin

(k,0)=x2(k)+

d
λ\xi
fmin

(k-1,0)

e(k,0)=d(k)

For i = 0,1,\ldots,N

\delta(k,i)=λ\delta(k-1,i)+

eb(k-1,i)ef(k,i)
\gamma(k-1,i)

\gamma(k,i+1)=\gamma(k,i)-

2(k,i)
e
b
d
\xi(k,i)
bmin

\kappab(k,i)=

\delta(k,i)
d
\xi(k,i)
fmin

\kappaf(k,i)=

\delta(k,i)
d
\xi(k-1,i)
bmin

eb(k,i+1)=eb(k-1,i)-\kappab(k,i)ef(k,i)

ef(k,i+1)=ef(k,i)-\kappaf(k,i)eb(k-1,i)

d
\xi
bmin

(k,i+1)=

d
\xi
bmin

(k-1,i)-\delta(k,i)\kappab(k,i)

d
\xi
fmin

(k,i+1)=

d
\xi
fmin

(k,i)-\delta(k,i)\kappaf(k,i)

Feedforward filtering

\deltaD(k,i)=λ\deltaD(k-1,i)+

e(k,i)eb(k,i)
\gamma(k,i)

vi(k)=

\deltaD(k,i)
d
\xi(k,i)
bmin

e(k,i+1)=e(k,i)-vi(k)eb(k,i)

End
End

Normalized lattice recursive least squares filter (NLRLS)

The normalized form of the LRLS has fewer recursions and variables. It can be calculated by applying a normalization to the internal variables of the algorithm which will keep their magnitude bounded by one. This is generally not used in real-time applications because of the number of division and square-root operations which comes with a high computational load.

NLRLS algorithm summary

The algorithm for a NLRLS filter can be summarized as

Initialization:
For i = 0,1,\ldots,N.

\overline{\delta}(-1,i)=0

(if x(k) = d(k) = 0 for k < 0)

\overline{\delta}D(-1,i)=0

\overline{e}b(-1,i)=0

End
2(-1)
\sigma
x

=

2(-1)
λ\sigma
d

=\varepsilon

Computation:
For k \ge 0
2(k)
\sigma
x

=

2(k-1)
λ\sigma
x

+x2(k)

(Input signal energy)
2(k)
\sigma
d

=

2(k-1)
λ\sigma
d

+d2(k)

(Reference signal energy)

\overline{e}b(k,0)=\overline{e}f(k,0)=

x(k)
\sigmax(k)

\overline{e}(k,0)=

d(k)
\sigmad(k)

For i = 0,1,\ldots,N

\overline{\delta}(k,i)=\delta(k-1,i)\sqrt{(1-

2(k-1,i))(1
\overline{e}
b

-

2(k,i))}
\overline{e}
f

+\overline{e}b(k-1,i)\overline{e}f(k,i)

\overline{e}b(k,i+1)=

\overline{e
b(k-1,i)

-\overline{\delta}(k,i)\overline{e}f(k,i)}{\sqrt{(1-\overline{\delta}2(k,i))(1-

2(k,i))}}
\overline{e}
f

\overline{e}f(k,i+1)=

\overline{e
f(k,i)

-\overline{\delta}(k,i)\overline{e}b(k-1,i)}{\sqrt{(1-\overline{\delta}2(k,i))(1-

2(k-1,i))}}
\overline{e}
b
Feedforward filter

\overline{\delta}D(k,i)=\overline{\delta}D(k-1,i)\sqrt{(1-

2(k,i))(1
\overline{e}
b

-\overline{e}2(k,i))}+\overline{e}(k,i)\overline{e}b(k,i)

\overline{e}(k,i+1)=

1
\sqrt{(1-\overline{e
2(k,i))(1
b

-

2(k,i))}}[\overline{e}(k,i)
\overline{\delta}
D

-\overline{\delta}D(k,i)\overline{e}b(k,i)]

End
End

See also

References

Notes and References

  1. Emannual C. Ifeacor, Barrie W. Jervis. Digital signal processing: a practical approach, second edition. Indianapolis: Pearson Education Limited, 2002, p. 718
  2. Steven Van Vaerenbergh, Ignacio Santamaría, Miguel Lázaro-Gredilla "Estimation of the forgetting factor in kernel recursive least squares", 2012 IEEE International Workshop on Machine Learning for Signal Processing, 2012, accessed June 23, 2016.
  3. Welch, Greg and Bishop, Gary "An Introduction to the Kalman Filter", Department of Computer Science, University of North Carolina at Chapel Hill, September 17, 1997, accessed July 19, 2011.
  4. Diniz, Paulo S.R., "Adaptive Filtering: Algorithms and Practical Implementation", Springer Nature Switzerland AG 2020, Chapter 7: Adaptive Lattice-Based RLS Algorithms. https://doi.org/10.1007/978-3-030-29057-3_7
  5. Albu, Kadlec, Softley, Matousek, Hermanek, Coleman, Fagan "Implementation of (Normalised) RLS Lattice on Virtex", Digital Signal Processing, 2001, accessed December 24, 2011.