This program implements the Adaptive Amplitude CRTRL (AACRTRL). Based on the paper "Nonlinear adaptive prediction of complex-valued signals by complex-valued PRNN", IEEE Transactions on Signal Processing, vol 53, no 5, 2005. Complex Valued Nonlinear Adaptive Filtering toolbox for MATLAB Supplementary to the book: "Complex Valued Nonlinear Adaptive Filters: Noncircularity, Widely Linear and Neural Models" by Danilo P. Mandic and Vanessa Su Lee Goh (c) Copyright Danilo P. Mandic 2009 http://www.commsp.ee.ic.ac.uk/~mandic %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You can obtain a copy of the GNU General Public License from http://www.gnu.org/copyleft/gpl.html or by writing to Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ...........................................
0001 % This program implements the Adaptive Amplitude CRTRL (AACRTRL). 0002 % 0003 % Based on the paper "Nonlinear adaptive prediction of complex-valued signals by complex-valued PRNN", 0004 % IEEE Transactions on Signal Processing, vol 53, no 5, 2005. 0005 % 0006 % 0007 % Complex Valued Nonlinear Adaptive Filtering toolbox for MATLAB 0008 % Supplementary to the book: 0009 % 0010 % "Complex Valued Nonlinear Adaptive Filters: Noncircularity, Widely Linear and Neural Models" 0011 % by Danilo P. Mandic and Vanessa Su Lee Goh 0012 % 0013 % (c) Copyright Danilo P. Mandic 2009 0014 % http://www.commsp.ee.ic.ac.uk/~mandic 0015 % 0016 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0017 % This program is free software; you can redistribute it and/or modify 0018 % it under the terms of the GNU General Public License as published by 0019 % the Free Software Foundation; either version 2 of the License, or 0020 % (at your option) any later version. 0021 % 0022 % This program is distributed in the hope that it will be useful, 0023 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0024 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0025 % GNU General Public License for more details. 0026 % 0027 % You can obtain a copy of the GNU General Public License from 0028 % http://www.gnu.org/copyleft/gpl.html or by writing to 0029 % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 0030 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0031 % 0032 % 0033 % ........................................... 0034 0035 close all; 0036 clear all; 0037 0038 M=4; % number of input tap (feedforward order) 0039 N=2; % number of neurons (feedback order) 0040 eta=0.1; % learning rate 0041 beta=1; % activation slope 0042 phi=0.1; % step size 0043 len=2000; % input signal sample size 0044 0045 % initialised all the variables to zeros 0046 w=zeros(M+N+1,N); % weights of neuron 0047 lamda=zeros(N,1); % adaptive amplitude 0048 PI_old=zeros(M+N+1,N,N); % previous sample PI 0049 PI_new=zeros(M+N+1,N,N); % current sample PI 0050 Y_old=zeros(N,1); % Previous output matrix 0051 Y_out=zeros(N,1); % output matrix 0052 x=zeros(M,1); % input samples 0053 % Eave=zeros(1,len); 0054 Elog=zeros(1,len); % cost function 0055 0056 for monte=1:30 % monte carlo simulation 0057 0058 monte 0059 0060 %weight initialization 0061 W_init=0.01*rand(M+N+1,N); %initialise the weight randomly 0062 w=W_init; 0063 0064 %initial lambda (adaptive amplitude) 0065 lamda(:,1)=1; 0066 0067 % generate input data 0068 noise=wgn(1,len,1); % white gaussian noise 0069 wgnoise=nonlinearfilt(noise); % passed the WGN into the nonlinear filter 0070 d=0.1*(wgnoise/max(wgnoise))+0.1; % scale the desired signal 0071 0072 % prediction signal 0073 xin(1)=0; 0074 xin(2:1:len)=d(1:1:len-1); %input signal 0075 0076 for k=1:len 0077 0078 x=[xin(k);x(1:M-1)]; % input sample to the network based on input tap size 0079 Y_old=[Y_out(1);Y_old(1:N-1)]; 0080 Uin=[Y_old;1;x]; % input to the network 0081 Vout=w'*Uin; 0082 0083 % First Activation Function (sigmoid) 0084 sig_function = lamda(:,k) ./ ( 1 + exp( -( beta .* Vout ))); 0085 0086 % First derivative Activation Function 0087 sig_function_der = beta .* sig_function .* ( 1 - sig_function ); 0088 0089 Y_out=sig_function; % value at the output of the neuron 0090 %Y_old=Y_out; % previous sample 0091 0092 e(:,k)=d(:,k)-Y_out(1,:); % error 0093 E(:,k)=(1/2)*(e(:,k)).^2; % cost function 0094 0095 % Adaptive amplitude 0096 lamda(:,k+1)=lamda(:,k) + phi.*e(:,k).*(sig_function ./ lamda(:,k)); 0097 0098 E_dB(k)=10*log10(E(:,k)); % evaluation of cost function in dB 0099 0100 % Compute values of pi 0101 0102 for r=1:1+M+N 0103 for s=1:N 0104 for t=1:N 0105 temp=0; 0106 for i=1:N 0107 temp=temp+w(r,i).*PI_old(i,s,t); 0108 end 0109 PI_new(r,s,t)=(sig_function_der(t,:)).*(Uin(r)+temp); 0110 end 0111 end 0112 end 0113 0114 PI_old=PI_new; 0115 0116 % Calculate weight changes 0117 dW=zeros(N,M+N+1); 0118 dW=eta.*e(:,k).*PI_new; 0119 w=w+dW(:,:,1); 0120 0121 end % for k 0122 0123 % Eave=Eave+E; 0124 Elog=Elog+E_dB; 0125 0126 end % monte 0127 0128 Elog=Elog/monte; 0129 % Eave_dB=10*log10(Eave/monte); 0130 0131 %plot graph 0132 figure(1); 0133 plot (1:len,d(1:len),'r',1:len,xin(1:len),'b') 0134 legend('Target', 'Input'); 0135 figure(2); 0136 plot(e) 0137 title('e(k)=d(k)-y(k)') 0138 figure(3); 0139 plot(E) 0140 title('E') 0141 % axis([0 500 -0.01 0.5]); 0142 figure(4); 0143 plot(Elog) 0144 title('Elog') 0145 % figure(5) 0146 % plot(Eave_dB) 0147 % title('Eave')