next up previous contents
Next: 5 asptsoiir1 Up: 6 Recursive Adaptive Algorithms Previous: 3 asptouterr   Contents


4 asptsharf

Purpose
Sample per sample IIR filtering and coefficient update using the Simple Hyperstable Adaptive Recursive Filter (SHARF) algorithm.

Syntax
[w,u,y,e,Px,Py]=asptsharf(N,M,w,u,xn,d,e,c,mu,Px,Py)

Description
asptsharf() implements the Simple Hyperstable Adaptive Recursive Filter (SHARF) algorithm. The SHARF algorithm adjusts the composite filter coefficients vector by minimizing the error signal as shown in Fig. 6.7. The main difference between SHARF and other LMS based IIR adaptive algorithms is that the SHARF algorithm uses a low pass filter $C(z)$ to smooth the error signal and uses the smoothed error as gradient. asptsharf() takes an input sample $x(n)$, a desired sample $d(n)$, the vector of the adaptive filter coefficients from previous iteration $w(n-1)$, the composite input vector $u(n-1)$, the step size vector $mu$, and returns the filter output $y(n)$, the error sample $e(n)$ and the updated vector of filter coefficients $w(n)$. The input and output parameters of asptsharf() for a recursive adaptive filter of $N$ numerator coefficients and $M$ denumerator coefficients are summarized below.
Input Parameters:
   N   : Number of coefficients of A(z)
   M   : Number of coefficients of B(z)
   w   : vector of adaptive filter coefficients
   u   : composite input / output delay line
   xn  : new input sample
   d   : new desired sample
   e   : error vector
   c   : error smoothing coefficients vector
   mu  : adaptation constant vector
   Px  : previously estimated power of input signal x(n)
   Py  : previously estimated power of output signal y(n)
Output Parameters:
   w   : updated adaptive coefficients
   u   : updated composite delay line
   y   : filter output y(n)
   e   : error signal e(n)
   Px  : updated power of input signal x(n)
   Py  : updated power of output signal y(n)



Figure 6.7: Block diagram of the SHARF algorithm.


\epsfig{file=/home/john/winD/docs/aspt/aspt/figs/sharf.eps,width=0.8\textwidth}



Example
Figure 6.8: The adaptive filter impulse response after convergence and the learning curve for the IIR system identification problem using the SHARF algorithm.
iter = 5000;                    % Number of samples to process
xn   = 2*(rand(iter,1)-0.5)  ;  % Input signal, zero mean random.
dn   = filter([0.6 -.01],[1 -0.4 0.6],xn); % Filter output 
en   = zeros(iter,1);           % error signal

% Initialize SHARF.
N=2; M=2; L = 7;
[u,w,e,c,d,mu,Px,Py]=init_sharf(N,M,L); 
mu = [0.02;0.02;0.02;0.02];

%% Processing Loop
for (m=1:iter)
	x = xn(m);
   d = dn(m)+ 1e-3*rand;   
   % update the filter
   [w,u,y,e,Px,Py]=asptsharf(N,M,w,u,x,d,e,c,mu,Px,Py);   
   % save the last error sample to plot later
   en(m,:) = e(1);  
end;

wp = filter(w(1:N),[1 ; -w(N+1:N+M)],[1; zeros(19,1)]);

% display the results
subplot(2,2,1);stem(wp); grid;
xlabel('filter response after convergence')
subplot(2,2,2);
eb = filter(.1, [1 -.9], en .* conj(en));
plot(10*log10(eb  ));grid
Running the above script will produce the graph shown in Fig. 6.8. The left side graph of the figure shows the adaptive filter impulse response after convergence. The right side graph shows the mean square error in dB versus time during the adaptation process, which is usually called the learning curve. The lower limit of the error signal power in the learning curve is defined here by the additive white noise added at the filter output (-60 dB).


\epsfig{file=/home/john/winD/docs/aspt/aspt/figs/sharfex1.eps,width=0.9\textwidth}

Algorithm
The SHARF algorithm uses a smoothed version of the error signal as the gradient vector. The filter transfer function is given by
\begin{displaymath}
w(z) = \frac{A(z)}{1-B(z)}
\end{displaymath} (58)

where


$\displaystyle A(z)$ $\textstyle =$ $\displaystyle a_0 + a_1 z^{-1} + ... + a_{N-1} z^{-N+1}$ (59)
$\displaystyle B(z)$ $\textstyle =$ $\displaystyle b_1 z^{-1} + b_2 z^{-2} + ... + b_M z^{-M}$ (60)

The current implementation of asptsharf() performs the following operations
  • Updates the composite input vector $\vu (n)$ using the current and previous samples of $x(n)$ and $y(n)$.
  • Filters the composite input vector $\vu (n)$ through the adaptive filter coefficients $\vw (n-1)$ to produce the filter output $y(n)$.
  • Calculates the error sample $e(n) = d(n) - y(n)$.
  • Calculates the smoothed error signal as shown in Fig. 6.7.
  • Updates the adaptive filter coefficients using the smoothed error and the composite input vector $\vu (n)$.

Remarks
  • Being an IIR filter, the adaptive filter $w(n)$ might become unstable during adaptation. This can be avoided by checking that the poles of the filter remain within the unit circle after each call to asptsharf.
  • asptsharf() supports both real and complex data and filters.
  • asptsharf() updates the composite input vector internally.



Resources
The resources required to implement the SHARF algorithm for a recursive adaptive filter of $N$ numerator coefficients and $M$ denumerator coefficients in real time is given in the table below. The computations given are those required to process one sample.


MEMORY $3N + 3M + 2L +4$
MULTIPLY $3N + 3M + L + 6$
ADD $N + M + L +2$
DIVIDE N+M


See Also
INIT_ SHARF, MODEL_ SHARF.

Reference
[2] and [10] for introduction to recursive adaptive filters.

next up previous contents
Next: 5 asptsoiir1 Up: 6 Recursive Adaptive Algorithms Previous: 3 asptouterr   Contents