- refactored
This commit is contained in:
Executable
+33
@@ -0,0 +1,33 @@
|
||||
function lms_eval(N, mu)
|
||||
|
||||
% lms_eval(N, mu)
|
||||
% Example: lms_eval(1000, 0.01)
|
||||
|
||||
h = [0 0 0 1 0 0 0 0];
|
||||
w = randn(1, length(h));
|
||||
|
||||
z_h = zeros(length(h)-1, 1);
|
||||
z_w = zeros(length(h)-1, 1);
|
||||
|
||||
x = zeros(1, length(h));
|
||||
|
||||
e_last = 0;
|
||||
p = 1.0;
|
||||
|
||||
for n=1:N,
|
||||
xs = 0.1*randn();
|
||||
p = 0.99*p + 0.01*xs*xs;
|
||||
x = [xs x(1:length(x)-1)];
|
||||
d = x*h';
|
||||
y = x*w';
|
||||
e = d - y;
|
||||
|
||||
w = w + mu*e*x*(1/(0.001+p));
|
||||
|
||||
e_last = 0.5*e_last + 0.5*e*e;
|
||||
_e(n) = e_last;
|
||||
_p(n) = p;
|
||||
end
|
||||
|
||||
plot(1:N, _e, 1:N, _p); grid;
|
||||
w=w'
|
||||
Reference in New Issue
Block a user