A list,

Least Mean Squares (LMS) is the most basic adaptive filtering algorithm.

LMS algorithm is a commonly used algorithm in adaptive filter. Different from Wiener algorithm, the coefficient of the system changes with the input sequence. Wiener algorithm intercepts a segment of the autocorrelation function of the input sequence to construct the optimal coefficient of the system. LMS algorithm is implemented by modifying the initial filter coefficients according to the minimum mean square error criterion. Therefore, theoretically speaking, the performance of LMS algorithm is better than wiener under the same conditions. However, LMS is gradually adjusted under the initial value, so there will be a period of adjustment before the system is stable. The adjustment time is controlled by the step factor. Within a certain range, the larger the step factor, the smaller the adjustment time, and the maximum value of step factor is the trace of R. LMS adopts the principle of minimum square error instead of the principle of minimum mean square error. The basic signal relationship is as follows:



Ii. Source code

% a variable step LMS algorithm clear all close all hold off sysORDER = 5; % number of taps t = 0:1/5000:1-0.0001; s = sin(2*pi*t); % Signal without noise N = size(t); M = length(t); % % The maximum eigenvalue % xx=rcorr(length(s),s); % [V,D]=eig(xx); % Dmax=max(max(D)); n = randn(N); % white gaussian noise [b,a] = butter(2,0.25); Gz = tf(b,a,-1); % y = lsim(Gz,s); Add sinusoidal signal z = n * STD (y)/(10* STD (n)); % standard deviation 0 noise signal x = s + z; Actual input signal dd = s; % expected output signal % start of algorithm w = zeros(1,sysorder); % weight vector initialization umax=0.45; % Set maximum step size umin=0.0003; % Set the minimum step size for I = 1:2u = umax; y(i) = x(i:i+4)* w' ; % System output e(I) = dd(I) -y (I); % error w = w + u * e(I) * x(I); % iteration equation end for I = 3:4 M - the if ((u > = umin) && (u < = umax)) (I) = y (I: I + 4) * x w '; % System output e(I) = dd(I) -y (I); % error w = w + u * e(I) * x(I); % Iterative equation u = ((e(I)* e(I -1)/((dd(I))^2)) * umax; End if u > umax u = umax; y(i) = x(i:i+4)* w' ; % System output e(I) = dd(I) -y (I); % error w = w + u * e(I) * x(I); % Iterative equation u = ((e(I)* e(I -1)/((dd(I))^2)) * umax; End if u < umin u = umin; y(i) = x(i:i+4)* w' ; % System output e(I) = dd(I) -y (I); % error w = w + u * e(I) * x(I); % Iterative equation u = ((e(I)* e(I -1)/((dd(I))^2)) * umax; End end % Mean square error st = 0; i = 1; while i <= M-4 a = (e(i))^2; st = st+a; out = (1/i)*st; yy(1,i) = out; i = i+1; End % % 图 片 Hold on; Subplot (z,'g') title(' noise ') % subplot(3,1,3) subplot(z,'g') title(' noise ') % subplot(3,1,3) Plot (x,'c') title(' noisy input signal ') figureCopy the code

3. Operation results



Fourth, note

Complete code added QQ1575304183