
function[w,J]=aaaveragesystidlms(a,b,c,h,mu,M,N,I)
%(average-system-identification)
%function[w,J]=aaaveragesystidlms(a,b,c,mu,M,N,I)
%a=controls the noise varance;b=controls if additional sine 
%function is desired;c=controls the noise variance internal
%to the system;mu=step size parameter;M=number of filter coefficients;
%N=length of desired signal d and input signal x;
%I=number of desired averages;
J=zeros(1,N);
w=zeros(1,M);
k=0:N-1;
for m=1:I
    x=a*randn(1,N)+b*sin(.1*pi*k);
    v=c*randn(1,length(x));
    o=filter(h,1,x);
    d=o+v;
    for n=M:N
        x1=x(n:-1:n-M+1);
        y(n)=w*x1';
        e(n)=d(n)-y(n);
        w=w+2*mu*e(n)*x1;
    end;
    E(m,:)=e.^2;
end;
J=sum(E,1)/I;

