Professional Documents
Culture Documents
Adaptive Filter PDF
Adaptive Filter PDF
Adaptive Filters
Introduction
9
The term adaptive filter implies changing the characteristic of a
filter in some automated fashion to obtain the best possible signal
quality in spite of changing signal/system conditions. Adaptive
filters are usually associated with the broader topic of statistical
signal processing. The operation of signal filtering by definition
implies extracting something desired from a signal containing
both desired and undesired components. With linear FIR and IIR
filters the filter output is obtained as a linear function of the
observation (signal applied) to the input. An optimum linear fil-
ter in the minimum mean square sense can be designed to extract
a signal from noise by minimizing the error signal formed by
subtracting the filtered signal from the desired signal. For noisy
signals with time varying statistics, this minimization process is
often done using an adaptive filter.
For statistically stationary inputs this solution is known as a
Wiener filter.1
+
d[n] e [ n ] Error
Signal
Desired
Signal -
Wiener MMSE
x[n] y[ n] Estimate
Observation Filter of d[n]
1. Simon Haykin, Adaptive Filter Theory, fourth edition, Prentice Hall, 2002.
Wiener Filter
An M tap discrete-time Wiener filter is of the form
M1
y[n] = wm x [ n m ] (9.1)
m=0
where the w m are referred to as the filter weights
Note: (9.1) tells us that the Wiener filter is just an M-tap
FIR filter
The quality of the filtered or estimated signal y [ n ] is deter-
mined from the error sequence e [ n ] = d [ n ] y [ n ]
The weights w m , m = 0, 1, , M 1 are chosen such that
2 2
E{e [n]} = E{(d[n] y[n]) } (9.2)
is minimized, that is we obtain the minimum mean-squared
error (MMSE)
The optimal weights are found by setting
2
E { e [ n ] } = 0, m = 0, 1, , M 1 (9.3)
wm
From the orthogonality principle1 we choose the weights
such that the error e [ n ] is orthogonal to the observations
(data), i.e.,
E { x [ n k ] ( d [ n ] y [ n ] ) } = 0, k = 0, 1, , M 1 (9.4)
xx [ 0 ] . . . xx [ M 1 ]
R xx = .. (9.8)
...
...
.
xx [ M + 1 ] . . . xx [ 0 ]
T
w o = w o0 w o1 w oM 1 (9.9)
N1
1
xx [ k ] ----
N x [ n + k ]x [ n ] (9.12)
n=0
N1
1
xd [ k ] ----
N x [ n + k ]d [ n ] (9.13)
n=0
Optimum at [1,1]
Mean Square Error
w1
w0
Adaptive
Algorithm
Least-Mean-Square Adaptation
Ideally the optimal weight solution can be obtained by apply-
ing the steepest descent method to the error surface, but since
the true gradient cannot be determined, we use a stochastic
gradient, which is simply the instantaneous estimate of R xx
and p xd from the available data, e.g.,
T
R xx = x [ n ]x [ n ] (9.14)
p xd = x [ n ]d [ n ] (9.15)
where
T
x[n] = x[n] x[n 1] x[n M + 1] (9.16)
The steps to the LMS algorithm, for each new sample at time
n, are:
Filter x [ n ] to produce:
M1
T
y[n] = w m [ n ]x [ n m ] = w [ n ]x [ n ] (9.17)
m=0
+
Adaptive -
Delay
x[n] Filter y[n]
e[n]
System Identification
+
Adaptive -
x[n] Filter y[n]
e[n]
Equalization
Training
Pattern
s[n] Delay d[n]
+
Plant/ Adaptive -
Channel + x [ n ] Filter y[n]
+
e[n]
Noise
Interference Canceling
Signal + d[n]
Interference
+
-
Interference
Adaptive
x[n] Filter y[n]
e[n]
z
Adaptive
x[n ] Filter y[n]
xd = filter([0 1],1,x);
% Initialize output vector y to zero
y = zeros(1,N+1);
% Initialize error vector e to zero
e = zeros(1,N+1);
% Initialize weight vector to zero
wo = zeros(1,M);
% Initialize filter memory to zero
z = zeros(1,M-1);
% Initialize a vector for holding xd of length M
xdm = zeros(1,M);
for k=1:N+1
% Filter one sample at a time
[y(k),z] = filter(wo,1,x(k),z);
% Form the error sequence
e(k) = x(k) - y(k);
% Update the weight vector
wo = wo + 2*mu*e(k)*xdm;
% Update vector used for correlation with e(k)
xdm = [xd(k) xdm(1:M-1)];
end %end loop on time index k
% Create filter frequency response
[Wo,F] = freqz(wo,1,512,1);
Wo = 20*log10(abs(Wo));
Convergence Occurs
in Here (~275 samples)
0.5
x[n]
-0.5
-1
-1.5
600 650 700 750 800 850 900 950 1000
0.5
y[n]
-0.5
-1
600 650 700 750 800 850 900 950 1000
Index n
-5
-10
Sinusoid Frequency
-15
|Wo(f)|dB
-20
-25
-30
-35
-40
-45
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
Normalized Frequency f
A C version of the above MATLAB code would be very sim-
ilar except all of the vector operations would have to be
replaced by for loops
TBD
Signal1 + d[n]
Signal2 (or noise)
+
-
Signal2
Adaptive
x[n] Filter y[n]
e[n]
///////////////////////////////////////////////////////////////////////
// Filename: Adaptive_ISRs.c
//
// Synopsis: Interrupt service routine for codec data transmit/receive
//
///////////////////////////////////////////////////////////////////////
#include "DSP_Config.h"
// Function Prototypes
long int rand_int(void);
#define LEFT 0
#define RIGHT 1
volatile union {
Uint32 UINT;
Int16 Channel[2];
} CodecDataIn, CodecDataOut;
a = (a*125) % 2796203;
return a;
}
///////////////////////////////////////////////////////////////////////
// Filename: main.c
//
#include "DSP_Config.h"
int main()
{
// call StartUp for application specific code
// defined in each application directory
StartUp();
///////////////////////////////////////////////////////////////////////
// Filename: StartUp.c
//
// Synopsis: Adaptive filter initialize
//
///////////////////////////////////////////////////////////////////////
#include "DSP_Config.h"
void StartUp()
{
InitDigitalOutputs();
// initialize filter weights and delay states
DSP_Init();
int T = 0;
for (T = 0; T < N; T++) //init variables
{
w[T] = 0.0; //init weights of adaptive FIR
delay[T] = 0.0; //init buffer for delay sampless
}
}
20
10
0
10
20
30
40
50
60
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency
20
10
0
10
20
30
40
50
60
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency
z
Adaptive
x[n ] Filter y[n]
//***********************************************************
// For left and right channel processing
// left and right help in packed 32 bit word
#define LEFT 0
#define RIGHT 1
union {Uint32 combo; short channel[2];} AIC23_data;
// Program globals
#define N 64 //# of coefficients of adapt FIR
#define Ns 10 //length splusn buffer
float splusn[Ns]; //buffer wideband signal+interference
float w[N]; //buffer for weights of adapt FIR
float delay[N]; //buffer for input to adapt FIR
Uint32 out_type = 1;//output type for slider
float alpha = 10;//alpha from slider
}
//out_type = 2;
/*
if (out_type == 1)//if slider in position 1
{
output = ((short)E);//WB signal
//output = ((short)wb_signal);//WB signal
}
else if (out_type == 2)
{
output =((short)yn);//NB signal
//output =((short)wb_signal);//NB signal
}*/
output =((short)yn);
output_sample(output);//output resultto left chan.
return;
}
a = (a*125) % 2796203;
return a;
}
30
Power Spectrum Magnitude (dB)
20
10
0
10
20
30
40
50
60
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency
30
Power Spectrum Magnitude (dB)
20
10
0
10
20
30
40
50
60
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency