%BMC normalization

for t=1:100
input(t) = 1.0;
time(t) = t;
end;


w(1) = 0.1;
threshold = 0.1;

for t=2:100
x(t) = input(t);
y(t) = w(t-1)*x(t);
if y(t) < threshold
w(t)=w(t-1)+0.1*x(t)*y(t);
else
w(t) = w(t-1) - 0.1*x(t)*y(t);
end;
end;

figure;
plot (time, w, 'b');hold;
plot (time, x, 'r');
plot (time, y, 'g');