# Connexions

You are here: Home » Content » Adaptive Filtering: LMS Algorithm

### Recently Viewed

This feature requires Javascript to be enabled.

### Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.

Module by: Matthew Berry. E-mail the author

Summary: (Blank Abstract)

Note: You are viewing an old version of this document. The latest version is available here.

## Introduction

This module is intended as an introduction to adaptive filtering.

Figure 1/ shows a block diagram for the use of adaptive filtering for system identification. The objective of the system is to adapt an FIR filter to match as closely as possible the response of an unknown filter, H H. Both the unknown system and thh adapting filter are fed with the same input, and each have respective outputs, yn y n (also referred to as the desired signal) and y ^ n y ^ n .

The FIR filter is adapted using the least mean-square algorithm. First the error signal is computed, en=yn y ^ n e n y n y ^ n , which provides a measure of how far our FIR filter is from the unknown system output. The coefficient update relation is a function of this error signal squared and is given by

h new i= h old i+μ2(|e|2 hi ) h new i h old i μ 2 h i e 2
(1)

The term inside the parenthesis represents the derivative, or gradient, of the squared-error with respect to the i'th coefficient, and the mu muterms represents a step-size, or how much gradient information is used to update each coefficient. After repeatedly adjusting each coefficient in the direction opposite to the gradient of the error, the adaptive filter should converge; that is, the difference between the unknown and adaptive systems should get smaller and smaller.

To express the gradient decent coefficient update equation in a more usable manner, we can rewrite the derivative of the squared-error term as |e|2 hi =2e hi e h i e 2 2 h i e e |e|2 hi =2(y y ^ ) hi e h i e 2 2 h i y y ^ e |e|2 hi =(2(y i =0N1hixni) hi )e h i e 2 2 h i y i 0 N 1 h i x n i e

|e|2 hi =2(xni)e h i e 2 2 x n i e
(2)
which in turn gives us the final LMS coefficient update,
h new i= h old i+μexni h new i h old i μ e x n i
(3)
The μ μ term, or step-size, directly affects how quickly the adaptive filter will converge toward the unknown system. If μ μ is very small, then the coefficients are not altered by a significant amount at each update. With a large step-size, more gradient information is included in each update; however, when the step-size is too large the coefficients may be changed too much and the filter will not converge.

## Matlab Simulation:

Simulate the system identification block diagram shown in Figure 1 on a sample by sample basis; that is, because the FIR filter changes at each sample, you must use a do loop in matlab rather than conv or filter function which use the same filter coefficients for the entire input sequence. For the unknown system, use the fourth order low-pass elliptical IIR filter designed for the IIR Filtering Lab.

Use Gaussian random noise your input, which can be generated in \matlab using the command randn. Simulate the system with an initial adaptive FIR of zeros, starting with an adaptive filter of length 32, and a step-size of 0.02 0.02. From your simulation you should be able to plot the error (or squared-error) as it evolves over time, as well as the final set of adapted coefficients. (How do they compare to the unknown system coefficients?)

With your simulation working, you will then want to experiment with different step-sizes and adaptive filter lengths

## Implementation

As with your matlab simulation, use the designed elliptical IIR filter as the unknown system in your DSP implementation.

Although the coefficient update equation is relatively straight forward, we strongly suggest that you look into the lms instruction available on the TI processor, as it is designed for just such an application and yields a very efficient implementation of the coefficient update equation.

To generate noise on the DSP you can use your PN generator code from Lab 5, but be sure to shift the PN register contents up to keep the sign bit random. (If the sign bit is always zero then the noise will not be zero-mean and will affect error convergence.) It is recommended that you output the desired signal, yn y n , the output of the adaptive filter, y ^ n y ^ n , and the error to the D/A for display on the oscilloscope.

When using the step-size suggested in the matlab simulation section you should notice that the error converges very quickly. You will want to try an extremely small μ μso that you can actually watch the error signal decrease towards zero in amplitude.

## Extensions:

If your project requires some modifications to the discussed system identification implementation, you will want to refer to the listed reference, Haykin, and consider some of the following questions regarding such modificiations:

• How would the system in Figure 1 change for different applications? (noise cancellation, equalization, etc.)
• What happens to the error when the step-size is too large or too small?
• How well does the error converge for different length adaptive FIR filters?
• What other types of coefficient update relations are possible other than the described LMS algorithm?

## References

• S. Haykin, Adaptive Filter Theory. Prentice Hall, 3rd ed., 1996.

## Content actions

### Give feedback:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks