Convergence and learning curve of 2nd order adaptive FIR system

** lab14_1.m * mw * 05/11/2007

Contents

Simulate impulse response and acf of 2nd order system

b = 0.1457*[1 2 1]; a = [1 -1.1430 .4128]; % numerator and denominator
% b = 0.3236*[1 2 1]; a = [1 -0.3695 .2722];
% b = 0.5084*[1 2 1]; a = [1  0.3690 .1958];
Nh = 41;                 % simulation lenght of impulse response for acf computation
h  = impz(b,a,Nh);        % impulse response
Rhh = conv(h,flipud(h)); % acf

Optimum 2nd order prediction coefficients and MMSE

R = [Rhh(Nh) Rhh(Nh+1);
     Rhh(Nh+1) Rhh(Nh)];     % correlation matrix
r = [Rhh(Nh+1); Rhh(Nh+2)];  % crosscorrelation vector
b_opt = R\r;                 % MMSE design
MSEopt = R(1,1) + b_opt'*R*b_opt - 2*b_opt'*r; % minimum MSE

Simulation of adaptiv system under ideal conditions

M = 61;               % number of iterations
randn('state',0);     % initialize random generator
w = randn(1,M);       % innovation
d = filter(b,a,w);    % IIR filter for process modeling
x = [0 d(1:M-1)];     % adaptive FIR system input signal
p   = zeros(2,1);     % prediction coefficients, initial values
mue = 0.05;                     % convergence parameter;
e   = d(1) - p(1)*x(1);         % error
MSE = R(1,1) + p'*R*p - 2*p'*r; % momentanous MSE
g   = 2*R*p - 2*r;              % gradient of MSE
e_mem = e; MSE_mem = MSE; g_mem = g; p_mem = p; % save data
p   = p - mue*inv(R)*g;         % update prediction coefficients
for n=2:M
    e   = d(n) - p(1)*x(n) - p(2)*x(n-1); % prediction error
    MSE = R(1,1) + p'*R*p - 2*p'*r;       % momentaneous MSE
    g   = 2*R*p - 2*r;                    % update gradient
    e_mem = [e_mem e]; MSE_mem = [MSE_mem MSE]; % save data
    g_mem = [g_mem g]; p_mem = [p_mem p];       % save data
    p = p - mue*inv(R)*g;                 % update prediction coefficients
end

Graphics: d, e and MSE

FIG1 = figure('Name','lab14_1 : Desired signal, predicted signal, error signal and learning curve',...
    'NumberTitle','off');
subplot(3,1,1),stem(0:M-1,d,'filled'), grid,
axis([0 M-1 -2 2])
xlabel('n \rightarrow'), ylabel('d[n] \rightarrow')
title('Desired signal')
subplot(3,1,2),stem(0:M-1,e_mem,'filled'), grid,
axis([0 M-1 -2 2])
xlabel('n \rightarrow'), ylabel('e[n] \rightarrow')
title('Error')
subplot(3,1,3),stem(0:M-1,MSE_mem/MSEopt,'filled'), grid
xlabel('n \rightarrow'), ylabel('MSE[n] / MSE_{opt} \rightarrow')
title('Mean-squared error')

Graphics: Convergence and contour lines for 2nd order prediction error (MSE)

c0 = -2:.02:2; c1 = -2:.02:2;
MSE = zeros(length(c0),length(c1));
for k=1:length(c0)
    for l=1:length(c1)
        cc = [c0(k); c1(l)] + b_opt;
        MSE(l,k) = R(1,1) + cc'*R*cc - 2*cc'*r;
    end
end
FIG2 = figure('Name','lab14_1 : Normalized MSE and convergence of coefficients c[n]',...
    'NumberTitle','off');
c = p_mem - repmat(b_opt,1,M);
V = [1 1.1 1.5 2 3 5 10];
[cc,h] = contour(c0,c1,MSE/MSEopt,V,'LineWidth',1,'Color','b'); grid
clabel(cc);
xlabel('c_0 \rightarrow'), ylabel('c_1 \rightarrow')
title('Convergence of coefficients and MSE')
hold on
plot(c(1,:),c(2,:),'o','MarkerFaceColor','b')
hold off