Question
Solution Preview
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
function Solution()%Q1
Npath= 100; % number of simulated paths
mu=0.1;%annual return for stock
sigma=0.3;
S0=50;
dt=1/(21*12); %time increment in years
T=1/4;
Nt=21*3;
t=0:dt:T;
DW=zeros(Npath,Nt+1); %initialize the increments of brownian motions to zero
%every row contains values for the a path and is of size Nt+1
% DW(q,i)= W((i+1)*dt)-W(i*dt) where q is the path
%since W((i+1)*dt)-W(i*dt) ~ N(0,dt)=sqrt(dt)*N(0,1) and they are
%independent
DW(:,2:Nt+1)=normrnd(0,1,Npath,Nt)*sqrt(dt);
W=cumsum(DW,2); % cumulative sum of each row
S=S0*exp((mu-sigma^2/2)*repmat(t,Npath,1)+W);...