BREAKING NEWS
Least mean squares filter

## Summary

Least mean squares (LMS) algorithms are a class of adaptive filter used to mimic a desired filter by finding the filter coefficients that relate to producing the least mean square of the error signal (difference between the desired and the actual signal). It is a stochastic gradient descent method in that the filter is only adapted based on the error at the current time. It was invented in 1960 by Stanford University professor Bernard Widrow and his first Ph.D. student, Ted Hoff.

## Problem formulation

### Relationship to the Wiener filter

The realization of the causal Wiener filter looks a lot like the solution to the least squares estimate, except in the signal processing domain. The least squares solution, for input matrix ${\displaystyle \mathbf {X} }$  and output vector ${\displaystyle {\boldsymbol {y}}}$  is

${\displaystyle {\boldsymbol {\hat {\beta }}}=(\mathbf {X} ^{\mathbf {T} }\mathbf {X} )^{-1}\mathbf {X} ^{\mathbf {T} }{\boldsymbol {y}}.}$

The FIR least mean squares filter is related to the Wiener filter, but minimizing the error criterion of the former does not rely on cross-correlations or auto-correlations. Its solution converges to the Wiener filter solution. Most linear adaptive filtering problems can be formulated using the block diagram above. That is, an unknown system ${\displaystyle \mathbf {h} (n)}$  is to be identified and the adaptive filter attempts to adapt the filter ${\displaystyle {\hat {\mathbf {h} }}(n)}$  to make it as close as possible to ${\displaystyle \mathbf {h} (n)}$ , while using only observable signals ${\displaystyle x(n)}$ , ${\displaystyle d(n)}$  and ${\displaystyle e(n)}$ ; but ${\displaystyle y(n)}$ , ${\displaystyle v(n)}$  and ${\displaystyle h(n)}$  are not directly observable. Its solution is closely related to the Wiener filter.

### Definition of symbols

${\displaystyle n}$  is the number of the current input sample
${\displaystyle p}$  is the number of filter taps
${\displaystyle \{\cdot \}^{H}}$  (Hermitian transpose or conjugate transpose)
${\displaystyle \mathbf {x} (n)=\left[x(n),x(n-1),\dots ,x(n-p+1)\right]^{T}}$
${\displaystyle \mathbf {h} (n)=\left[h_{0}(n),h_{1}(n),\dots ,h_{p-1}(n)\right]^{T},\quad \mathbf {h} (n)\in \mathbb {C} ^{p}}$
${\displaystyle y(n)=\mathbf {h} ^{H}(n)\cdot \mathbf {x} (n)}$
${\displaystyle d(n)=y(n)+\nu (n)}$
${\displaystyle {\hat {\mathbf {h} }}(n)}$  estimated filter; interpret as the estimation of the filter coefficients after n samples
${\displaystyle e(n)=d(n)-{\hat {y}}(n)=d(n)-{\hat {\mathbf {h} }}^{H}(n)\cdot \mathbf {x} (n)}$

## Idea

The basic idea behind LMS filter is to approach the optimum filter weights ${\displaystyle (R^{-1}P)}$ , by updating the filter weights in a manner to converge to the optimum filter weight. This is based on the gradient descent algorithm. The algorithm starts by assuming small weights (zero in most cases) and, at each step, by finding the gradient of the mean square error, the weights are updated. That is, if the MSE-gradient is positive, it implies the error would keep increasing positively if the same weight is used for further iterations, which means we need to reduce the weights. In the same way, if the gradient is negative, we need to increase the weights. The weight update equation is

${\displaystyle W_{n+1}=W_{n}-\mu \nabla \varepsilon [n],}$

where ${\displaystyle \varepsilon }$  represents the mean-square error and ${\displaystyle \mu }$  is a convergence coefficient.

The negative sign shows that we go down the slope of the error, ${\displaystyle \varepsilon }$  to find the filter weights, ${\displaystyle W_{i}}$ , which minimize the error.

The mean-square error as a function of filter weights is a quadratic function which means it has only one extremum, that minimizes the mean-square error, which is the optimal weight. The LMS thus, approaches towards this optimal weights by ascending/descending down the mean-square-error vs filter weight curve.

## Derivation

The idea behind LMS filters is to use steepest descent to find filter weights ${\displaystyle {\hat {\mathbf {h} }}(n)}$  which minimize a cost function. We start by defining the cost function as

${\displaystyle C(n)=E\left\{|e(n)|^{2}\right\}}$

where ${\displaystyle e(n)}$  is the error at the current sample n and ${\displaystyle E\{\cdot \}}$  denotes the expected value.

This cost function (${\displaystyle C(n)}$ ) is the mean square error, and it is minimized by the LMS. This is where the LMS gets its name. Applying steepest descent means to take the partial derivatives with respect to the individual entries of the filter coefficient (weight) vector

${\displaystyle \nabla _{{\hat {\mathbf {h} }}^{H}}C(n)=\nabla _{{\hat {\mathbf {h} }}^{H}}E\left\{e(n)\,e^{*}(n)\right\}=2E\left\{\nabla _{{\hat {\mathbf {h} }}^{H}}(e(n))\,e^{*}(n)\right\}}$

where ${\displaystyle \nabla }$  is the gradient operator

${\displaystyle \nabla _{{\hat {\mathbf {h} }}^{H}}(e(n))=\nabla _{{\hat {\mathbf {h} }}^{H}}\left(d(n)-{\hat {\mathbf {h} }}^{H}\cdot \mathbf {x} (n)\right)=-\mathbf {x} (n)}$
${\displaystyle \nabla C(n)=-2E\left\{\mathbf {x} (n)\,e^{*}(n)\right\}}$

Now, ${\displaystyle \nabla C(n)}$  is a vector which points towards the steepest ascent of the cost function. To find the minimum of the cost function we need to take a step in the opposite direction of ${\displaystyle \nabla C(n)}$ . To express that in mathematical terms

${\displaystyle {\hat {\mathbf {h} }}(n+1)={\hat {\mathbf {h} }}(n)-{\frac {\mu }{2}}\nabla C(n)={\hat {\mathbf {h} }}(n)+\mu \,E\left\{\mathbf {x} (n)\,e^{*}(n)\right\}}$

where ${\displaystyle {\frac {\mu }{2}}}$  is the step size(adaptation constant). That means we have found a sequential update algorithm which minimizes the cost function. Unfortunately, this algorithm is not realizable until we know ${\displaystyle E\left\{\mathbf {x} (n)\,e^{*}(n)\right\}}$ .

Generally, the expectation above is not computed. Instead, to run the LMS in an online (updating after each new sample is received) environment, we use an instantaneous estimate of that expectation. See below.

## Simplifications

For most systems the expectation function ${\displaystyle {E}\left\{\mathbf {x} (n)\,e^{*}(n)\right\}}$  must be approximated. This can be done with the following unbiased estimator

${\displaystyle {\hat {E}}\left\{\mathbf {x} (n)\,e^{*}(n)\right\}={\frac {1}{N}}\sum _{i=0}^{N-1}\mathbf {x} (n-i)\,e^{*}(n-i)}$

where ${\displaystyle N}$  indicates the number of samples we use for that estimate. The simplest case is ${\displaystyle N=1}$

${\displaystyle {\hat {E}}\left\{\mathbf {x} (n)\,e^{*}(n)\right\}=\mathbf {x} (n)\,e^{*}(n)}$

For that simple case the update algorithm follows as

${\displaystyle {\hat {\mathbf {h} }}(n+1)={\hat {\mathbf {h} }}(n)+\mu \mathbf {x} (n)\,e^{*}(n)}$

Indeed, this constitutes the update algorithm for the LMS filter.

## LMS algorithm summary

The LMS algorithm for a ${\displaystyle p}$ th order filter can be summarized as

 Parameters: ${\displaystyle p=}$  filter order ${\displaystyle \mu =}$  step size Initialisation: ${\displaystyle {\hat {\mathbf {h} }}(0)=\operatorname {zeros} (p)}$ Computation: For ${\displaystyle n=0,1,2,...}$ ${\displaystyle \mathbf {x} (n)=\left[x(n),x(n-1),\dots ,x(n-p+1)\right]^{T}}$ ${\displaystyle e(n)=d(n)-{\hat {\mathbf {h} }}^{H}(n)\mathbf {x} (n)}$ ${\displaystyle {\hat {\mathbf {h} }}(n+1)={\hat {\mathbf {h} }}(n)+\mu \,e^{*}(n)\mathbf {x} (n)}$

## Convergence and stability in the mean

As the LMS algorithm does not use the exact values of the expectations, the weights would never reach the optimal weights in the absolute sense, but a convergence is possible in mean. That is, even though the weights may change by small amounts, it changes about the optimal weights. However, if the variance with which the weights change, is large, convergence in mean would be misleading. This problem may occur, if the value of step-size ${\displaystyle \mu }$  is not chosen properly.

If ${\displaystyle \mu }$  is chosen to be large, the amount with which the weights change depends heavily on the gradient estimate, and so the weights may change by a large value so that gradient which was negative at the first instant may now become positive. And at the second instant, the weight may change in the opposite direction by a large amount because of the negative gradient and would thus keep oscillating with a large variance about the optimal weights. On the other hand, if ${\displaystyle \mu }$  is chosen to be too small, time to converge to the optimal weights will be too large.

Thus, an upper bound on ${\displaystyle \mu }$  is needed which is given as ${\displaystyle 0<\mu <{\frac {2}{\lambda _{\mathrm {max} }}}}$

where ${\displaystyle \lambda _{\max }}$  is the greatest eigenvalue of the autocorrelation matrix ${\displaystyle {\mathbf {R} }=E\{{\mathbf {x} }(n){\mathbf {x} ^{H}}(n)\}}$ . If this condition is not fulfilled, the algorithm becomes unstable and ${\displaystyle {\hat {h}}(n)}$  diverges.

Maximum convergence speed is achieved when

${\displaystyle \mu ={\frac {2}{\lambda _{\mathrm {max} }+\lambda _{\mathrm {min} }}},}$

where ${\displaystyle \lambda _{\min }}$  is the smallest eigenvalue of ${\displaystyle {\mathbf {R} }}$ . Given that ${\displaystyle \mu }$  is less than or equal to this optimum, the convergence speed is determined by ${\displaystyle \lambda _{\min }}$ , with a larger value yielding faster convergence. This means that faster convergence can be achieved when ${\displaystyle \lambda _{\max }}$  is close to ${\displaystyle \lambda _{\min }}$ , that is, the maximum achievable convergence speed depends on the eigenvalue spread of ${\displaystyle {\mathbf {R} }}$ .

A white noise signal has autocorrelation matrix ${\displaystyle {\mathbf {R} }=\sigma ^{2}{\mathbf {I} }}$  where ${\displaystyle \sigma ^{2}}$  is the variance of the signal. In this case all eigenvalues are equal, and the eigenvalue spread is the minimum over all possible matrices. The common interpretation of this result is therefore that the LMS converges quickly for white input signals, and slowly for colored input signals, such as processes with low-pass or high-pass characteristics.

It is important to note that the above upperbound on ${\displaystyle \mu }$  only enforces stability in the mean, but the coefficients of ${\displaystyle {\hat {h}}(n)}$  can still grow infinitely large, i.e. divergence of the coefficients is still possible. A more practical bound is

${\displaystyle 0<\mu <{\frac {2}{\mathrm {tr} \left[{\mathbf {R} }\right]}},}$

where ${\displaystyle \mathrm {tr} [{\mathbf {R} }]}$  denotes the trace of ${\displaystyle {\mathbf {R} }}$ . This bound guarantees that the coefficients of ${\displaystyle {\hat {h}}(n)}$  do not diverge (in practice, the value of ${\displaystyle \mu }$  should not be chosen close to this upper bound, since it is somewhat optimistic due to approximations and assumptions made in the derivation of the bound).

## Normalized least mean squares filter (NLMS)

The main drawback of the "pure" LMS algorithm is that it is sensitive to the scaling of its input ${\displaystyle x(n)}$ . This makes it very hard (if not impossible) to choose a learning rate ${\displaystyle \mu }$  that guarantees stability of the algorithm (Haykin 2002). The Normalised least mean squares filter (NLMS) is a variant of the LMS algorithm that solves this problem by normalising with the power of the input. The NLMS algorithm can be summarised as:

 Parameters: ${\displaystyle p=}$  filter order ${\displaystyle \mu =}$  step size Initialization: ${\displaystyle {\hat {\mathbf {h} }}(0)=\operatorname {zeros} (p)}$ Computation: For ${\displaystyle n=0,1,2,...}$ ${\displaystyle \mathbf {x} (n)=\left[x(n),x(n-1),\dots ,x(n-p+1)\right]^{T}}$ ${\displaystyle e(n)=d(n)-{\hat {\mathbf {h} }}^{H}(n)\mathbf {x} (n)}$ ${\displaystyle {\hat {\mathbf {h} }}(n+1)={\hat {\mathbf {h} }}(n)+{\frac {\mu \,e^{*}(n)\mathbf {x} (n)}{\mathbf {x} ^{H}(n)\mathbf {x} (n)}}}$

### Optimal learning rate

It can be shown that if there is no interference (${\displaystyle v(n)=0}$ ), then the optimal learning rate for the NLMS algorithm is

${\displaystyle \mu _{opt}=1}$

and is independent of the input ${\displaystyle x(n)}$  and the real (unknown) impulse response ${\displaystyle \mathbf {h} (n)}$ . In the general case with interference (${\displaystyle v(n)\neq 0}$ ), the optimal learning rate is

${\displaystyle \mu _{opt}={\frac {E\left[\left|y(n)-{\hat {y}}(n)\right|^{2}\right]}{E\left[|e(n)|^{2}\right]}}}$

The results above assume that the signals ${\displaystyle v(n)}$  and ${\displaystyle x(n)}$  are uncorrelated to each other, which is generally the case in practice.

### Proof

Let the filter misalignment be defined as ${\displaystyle \Lambda (n)=\left|\mathbf {h} (n)-{\hat {\mathbf {h} }}(n)\right|^{2}}$ , we can derive the expected misalignment for the next sample as:

${\displaystyle E\left[\Lambda (n+1)\right]=E\left[\left|{\hat {\mathbf {h} }}(n)+{\frac {\mu \,e^{*}(n)\mathbf {x} (n)}{\mathbf {x} ^{H}(n)\mathbf {x} (n)}}-\mathbf {h} (n)\right|^{2}\right]}$
${\displaystyle E\left[\Lambda (n+1)\right]=E\left[\left|{\hat {\mathbf {h} }}(n)+{\frac {\mu \,\left(v^{*}(n)+y^{*}(n)-{\hat {y}}^{*}(n)\right)\mathbf {x} (n)}{\mathbf {x} ^{H}(n)\mathbf {x} (n)}}-\mathbf {h} (n)\right|^{2}\right]}$

Let ${\displaystyle \mathbf {\delta } ={\hat {\mathbf {h} }}(n)-\mathbf {h} (n)}$  and ${\displaystyle r(n)={\hat {y}}(n)-y(n)}$

${\displaystyle E\left[\Lambda (n+1)\right]=E\left[\left|\mathbf {\delta } (n)-{\frac {\mu \,\left(v(n)+r(n)\right)\mathbf {x} (n)}{\mathbf {x} ^{H}(n)\mathbf {x} (n)}}\right|^{2}\right]}$
${\displaystyle E\left[\Lambda (n+1)\right]=E\left[\left(\mathbf {\delta } (n)-{\frac {\mu \,\left(v(n)+r(n)\right)\mathbf {x} (n)}{\mathbf {x} ^{H}(n)\mathbf {x} (n)}}\right)^{H}\left(\mathbf {\delta } (n)-{\frac {\mu \,\left(v(n)+r(n)\right)\mathbf {x} (n)}{\mathbf {x} ^{H}(n)\mathbf {x} (n)}}\right)\right]}$

Assuming independence, we have:

${\displaystyle E\left[\Lambda (n+1)\right]=\Lambda (n)+E\left[\left({\frac {\mu \,\left(v(n)+r(n)\right)\mathbf {x} (n)}{\mathbf {x} ^{H}(n)\mathbf {x} (n)}}\right)^{H}\left({\frac {\mu \,\left(v(n)+r(n)\right)\mathbf {x} (n)}{\mathbf {x} ^{H}(n)\mathbf {x} (n)}}\right)\right]-2E\left[{\frac {\mu |r(n)|^{2}}{\mathbf {x} ^{H}(n)\mathbf {x} (n)}}\right]}$
${\displaystyle E\left[\Lambda (n+1)\right]=\Lambda (n)+{\frac {\mu ^{2}E\left[|e(n)|^{2}\right]}{\mathbf {x} ^{H}(n)\mathbf {x} (n)}}-{\frac {2\mu E\left[|r(n)|^{2}\right]}{\mathbf {x} ^{H}(n)\mathbf {x} (n)}}}$

The optimal learning rate is found at ${\displaystyle {\frac {dE\left[\Lambda (n+1)\right]}{d\mu }}=0}$ , which leads to:

${\displaystyle 2\mu E\left[|e(n)|^{2}\right]-2E\left[|r(n)|^{2}\right]=0}$
${\displaystyle \mu ={\frac {E\left[|r(n)|^{2}\right]}{E\left[|e(n)|^{2}\right]}}}$