Convergence and learning curve of 2nd order RLS predictor

** lab16_3.m * mw * 05/20/2007

Contents

Input dialog

prompt = {'Order of predictor p'};
dlg_title = 'lab16_3'; num_lines = 1; def = {'3'};
answer = inputdlg(prompt,dlg_title,num_lines,def);
if isempty(answer)
    Np = 3;                     % default
else
    Np = str2num(answer{1});    % prediction order
end
[x,fs,bits]=wavread('speech');  % speech signal
%[x,fs,bits]=wavread('handel'); % audio signal
Lx = length(x);                 % number of samples
sound(x,fs,bits);

Linear prediction (long term)

Rxx = xcorr(x,'unbiased'); % estimate mean autocorrelation sequence
r = Rxx(Lx:Lx+Np+1);       % relevant coefficients for Levinson-Durbin alg. Rxx[0],Rxx[1],...
[a,E,k] = levinson(r,Np);  % Levinson-Durbin alg. (Signal Processing Toolbox)
[e1 g] = latcfilt(k,x);     % residuum e[n] (prediction error) (Signal Processing Toolbox)
clear g;                   % delete backward lattice filter output signal
Re1e1 = xcorr(e1,'unbiased'); % estimate autocorrelation sequence of residuum
fprintf('lab16_3 : Reflection coefficients\n')
for m=1:Np
    fprintf([' k',num2str(m),' = %g \n'],k(m))
end
fprintf('Audio signal        Rxx[0] = %g \n',Rxx(Lx))
fprintf('Residual signal     Ree[0] = %g \n',Re1e1(Lx))
fprintf('Prediction error    E      = %g \n',E)
fprintf('Prediction gain     Gp     = %g dB\n\n',10*log10(Rxx(Lx)/Re1e1(Lx)))
pause(1+Lx/fs)
sound(e1,fs,bits);        % residuum
lab16_3 : Reflection coefficients
 k1 = -0.982861 
 k2 = 0.47298 
 k3 = 0.16021 
Audio signal        Rxx[0] = 0.031681 
Residual signal     Ree[0] = 0.000816771 
Prediction error    E      = 0.000814322 
Prediction gain     Gp     = 15.887 dB

Simulation of adaptiv system - RLS algorithm

p = Np;             % prediction order (FIR filter order +1)
rls = struct('alpha',1/512,'beta',1/128,'b',zeros(p,1),'e',0,'x',zeros(p-1,1),...
             'R_1',eye(p),'Mode','e*x');
% noise = 10^(-20/10)*randn(1,Lx); % AWGN
[y,e2,rls,SAVEb] = rls_algorithm([0 x(1:Lx-1)'],x,rls);
pause(1+Lx/fs)
sound(e2,fs,bits);        % residuum

Graphics

figure('Name',['lab16_3 : pth order linear prediction -> p = ',...
    num2str(Np),' , fs = ',num2str(fs)],'NumberTitle','off');
L2 = 400;
t1 = (0:Lx-1)/fs; t2 = 1e3*(0:L2)/fs;
subplot(3,2,1), plot(t1,x(1:Lx)),grid
xlabel('t in s \rightarrow'), ylabel('x(t) \rightarrow')
title('Audio signal (original)')
subplot(3,2,2), plot(t2,Rxx(Lx:Lx+L2)/Rxx(Lx)),grid
xlabel('\tau in ms \rightarrow'), ylabel('R_{xx}(\tau) / R_{xx}(0) \rightarrow')
title('ACF')
subplot(3,2,3), plot(t1,e1(1:Lx)),grid
xlabel('t in s \rightarrow'), ylabel('e_{LTP}(t) \rightarrow')
title('Prediction error - long term prediction')
subplot(3,2,4), plot(t2,Re1e1(Lx:Lx+L2)/Rxx(Lx),0,Re1e1(Lx)/Rxx(Lx),'o'),grid
xlabel('\tau in ms \rightarrow'), ylabel('R_{ee,LTP}(\tau) / R_{xx}(0) \rightarrow')
title('ACF with long term prediction)')
subplot(3,2,5), plot(t1,e2(1:Lx)),grid
xlabel('t in s \rightarrow'), ylabel('e_{RLS}(t) \rightarrow')
title('Prediction error with RLS algorithm')
Re2e2 = xcorr(e2,'unbiased');  % estimate mean autocorrelation sequence
subplot(3,2,6), plot(t2,Re2e2(Lx:Lx+L2)/Rxx(Lx),0,Re2e2(Lx)/Rxx(Lx),'o'),grid
xlabel('\tau in ms \rightarrow'), ylabel('R_{ee,RLS}(\tau) / R_{xx}(0) \rightarrow')
title('ACF with RLS algorithm')
figure('Name',['lab16_3 : pth order linear prediction -> p = ',...
    num2str(Np),' , fs = ',num2str(fs)],'NumberTitle','off');
subplot(2,1,1), plot(t1,SAVEb(1,1:Lx)),grid
xlabel('t in s \rightarrow'), ylabel('b_0(t) \rightarrow')
title('FIR filter coefficient')
subplot(2,1,2), plot(t1,SAVEb(2,1:Lx)),grid
xlabel('t in s \rightarrow'), ylabel('b_1(t) \rightarrow')