% simulation of the Ito process I(t) = (integral from 0 to t) W(s)dW(s)
%    or simply dI = W dW 

M = 7;
T = 10;
N = 1000; 
h = T/N;
t = (0:N)*h;
Z = randn(M,N);

W  = zeros(M,N+1);
II = zeros(M,N+1);

for i=1:N
    W(:,i+1)=W(:,i)+sqrt(h)*Z(:,i);
end

for i=1:N
    II(:,i+1) = II(:,i) + W(:,i).*(W(:,i+1)-W(:,i));
end

% color plot - for up to 7 colors only! 
hold on
plot(t,II(1,:),'b')
plot(t,II(2,:),'r')
plot(t,II(3,:),'g')
plot(t,II(4,:),'y')
plot(t,II(5,:),'k')
plot(t,II(6,:),'m')
plot(t,II(7,:),'c')
