Convergence and learning curve of 2nd order RLS predictor
** lab16_1.m * mw * 05/20/2007
Contents
2nd order system - MSE optimum 2nd order prediction
a = [1 -.71 .25]; % denominator coefficients b = .24192*[1 2 1]; % numerator coefficients Nh = 51; % simulation lenght of impulse response h = impz(b,a,Nh); % impulse response Rhh = conv(h,flipud(h)); % acf R = [Rhh(Nh) Rhh(Nh+1); Rhh(Nh+1) Rhh(Nh)]/Rhh(Nh); % correlation matrix r = [Rhh(Nh+1); Rhh(Nh+2)]/Rhh(Nh); % cross-correlation vector fprintf('lab16_2 2nd order correlation matrix\n') fprintf('Rxx[1,1] = %+6.4f ; Rxx[1,2] = %+6.4f \n',R(1,1),R(1,2)) fprintf('Rxx[2,1] = %+6.4f ; Rxx[2,2] = %+6.4f \n',R(2,1),R(2,2)) fprintf('crosscorrelation vector\n') fprintf('rxd[1] = %+6.4f ; rxd[2] = %+6.4f \n',r(1),r(2)) b_opt = R\r; % optimum 2nd order prediction coefficients MSEopt = R(1,1) + b_opt'*R*b_opt - 2*b_opt'*r; % minimum MSE fprintf('prediction coefficients and error signal power\n') fprintf('2nd order : b0 = %+6.4f ; b1 = %+6.4f ; MSEopt = %+6.4f \n',b_opt(1),b_opt(2),MSEopt) lambda = eig(R); % eigenvalues of the correlation matrix fprintf('Eigenvalues : lambda1 = %+6.4f ; lambda2 = %+6.4f \n',lambda(1),lambda(2)) R_1 = inv(R); % inverse correlation matrix fprintf('inverse correlation matrix\n') fprintf('Rxx^-1[1,1] = %+6.4f ; Rxx^-1[1,2] = %+6.4f \n',R_1(1,1),R_1(1,2)) fprintf('Rxx^-1[2,1] = %+6.4f ; Rxx^-1[2,2] = %+6.4f \n',R_1(2,1),R_1(2,2))
lab16_2 2nd order correlation matrix Rxx[1,1] = +1.0000 ; Rxx[1,2] = +0.7885 Rxx[2,1] = +0.7885 ; Rxx[2,2] = +1.0000 crosscorrelation vector rxd[1] = +0.7885 ; rxd[2] = +0.3684 prediction coefficients and error signal power 2nd order : b0 = +1.3168 ; b1 = -0.6700 ; MSEopt = +0.2085 Eigenvalues : lambda1 = +0.2115 ; lambda2 = +1.7885 inverse correlation matrix Rxx^-1[1,1] = +2.6439 ; Rxx^-1[1,2] = -2.0848 Rxx^-1[2,1] = -2.0848 ; Rxx^-1[2,2] = +2.6439
sample function of model process
M = 1e5; % number of iterations randn('state',0); w = randn(1,M); % innovation d = filter(b,a,w); % IIR filter for process modeling - desired signal
simulation of adaptiv system
initalization
x = [0 d(1:M-1)]; % input signal for adaptive FIR system p = 2; % prediction order (FIR filter order = p-1)
RLS algorithm
rls = struct('alpha',1/64,'beta',1/64,'b',b_opt,'x',zeros(p-1,1),'R_1',R_1); [y,e,rls,SAVEb] = rls_algorithm(x,d,rls); fprintf('final prediction coefficients\n') fprintf('(%i) b0 = %6.4f ; b1 = %6.4f\n',M,rls.b(1),rls.b(2)) EccessMSE = sum(e.^2)/M - MSEopt; fprintf('Misadjustment = %6.4f\n\n',EccessMSE/MSEopt)
final prediction coefficients (100000) b0 = 1.4700 ; b1 = -0.7348 Misadjustment = 0.0343
Graphics
b = SAVEb(1:p,:); LC = zeros(1,M); for n = 1:M LC(n) = R(1,1) + b(1:2,n)'*R*b(1:2,n) - 2*b(1:2,n)'*r; % MSE, learning curve end FIG1 = figure('Name','lab16_2 : Desired signal, prediction error and variance estimate ',... 'NumberTitle','off'); subplot(2,1,1),plot(0:M-1,d,'LineWidth',2), grid, axis([0 M-1 -4 4]) xlabel('n \rightarrow'), ylabel('d[n] \rightarrow') title('Desired signal') subplot(2,1,2),plot(0:M-1,e,'LineWidth',2), grid, axis([0 M-1 -4 4]) xlabel('n \rightarrow'), ylabel('e[n] \rightarrow') title('Error') FIG2 = figure('Name','lab16_2 : Learning curve','NumberTitle','off'); plot(1:M-1,LC(1:M-1)/MSEopt,'LineWidth',2), grid axis([1 M 1 5]); xlabel('n \rightarrow'), ylabel('MSE[n] / MSEopt \rightarrow') title('Learning curve (MSE)') % 2nd order prediction error - MSE c0 = -2:.05:2; c1 = -2:.05: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 FIG3 = figure('Name','lab16_2 : Realtiv MSE and convergence of coefficients c[n]',... 'NumberTitle','off'); c = b(1:2,:) - repmat(b_opt,1,M); V = [1 1.2 1.5 2 3 4 6]; [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','MarkerSize',4,'MarkerFaceColor','b') hold off