MSE of 2nd order linear prediction

** lab10_2.m * mw * 04/19/2007

Contents

Impulse response and acf of 2nd order system

b = .242*[1 2 1]; a = [1 -.71 .25]; % denominator and numerator coefficients
N = 21;                  % simulation lenght of impulse response
h = impz(b,a,N);         % impulse response
Rhh = conv(h,flipud(h)); % acf
% graphics
graph10_h(h,Rhh,'lab10_2 : Impulse response, acf and pds')

Optimum 2nd order prediction coefficients

R = [Rhh(N) Rhh(N+1);
     Rhh(N+1) Rhh(N)]/Rhh(N);     % acf matrix
r = [Rhh(N+1); Rhh(N+2)]/Rhh(N);  % acf vector
b_opt = R\r;                      % MSE design
MSEopt_2 = R(1,1) + b_opt'*R*b_opt - 2*b_opt'*r;
fprintf('lab10_2 : Prediction coefficients and error signal power\n')
fprintf(' 2nd order : b0 = %g ; b1 = %g ; MSEopt = %g \n\n',b_opt(1),b_opt(2),MSEopt_2)
lab10_2 : Prediction coefficients and error signal power
 2nd order : b0 = 1.3168 ; b1 = -0.669952 ; MSEopt = 0.208465 

2nd order prediction error - MSE

b0 = -4:.1:4; b1 = -4:.1:4;
MSE = zeros(length(b0),length(b1));
for k=1:length(b0)
    for l=1:length(b1)
        bb = [b0(k); b1(l)];
        MSE(l,k) = R(1,1) + bb'*R*bb - 2*bb'*r;
    end
end
% graphics
FIG1 = figure('Name','lab10_2 : Contour lines of MSE for 2nd order predictor',...
    'NumberTitle','off');
V = [.2 .3 .5 1 2 5 10];
[c,h] = contour(b0,b1,MSE,V); grid
clabel(c);
xlabel('b_0 \rightarrow'), ylabel('b_1 \rightarrow')
title('Contour lines of MSE for 2nd order predictor')
FIG2 = figure('Name','lab10_2 : MSE for 2nd order predictor',...
    'NumberTitle','off');
mesh(b0,b1,MSE);
xlabel('b_0 \rightarrow'),ylabel('b_1 \rightarrow'), zlabel(' MSE \rightarrow')
title('MSE for 2nd order predictor')