% Time step in years for daily increments
Dt = 1/252;
% All the time points
t = [0:Dt:T];
m = length(t)-1;
fprintf('Number of time steps = %d, time step = %.4f years\n', m, Dt);
% N = number of simulations
N = 8000;
k=55000;
%Model S(t + Dt)=S*exp((r-0.5*sigma^2)*T + sigma*sqrt(T)*Z);
% where wt is a standard normal random variable
Z = randn(m, N);
z = exp((r-0.5*sigma^2)*Dt + sigma*sqrt(Dt)*Z);
S = S0*[ones(1,N); cumprod(z)];