function [t,s,dt] = stockBS(n,sig,mu)

% stockBS creates a random stock path using the 
%         Black-Scholes model
%
% [t,s,dt] = stockBS(n,sig,mu)

S0 = 10;  % initial stock value
tEnd = 1; % 1 year

dt = tEnd/n;

t = zeros(1,n+1);
s = zeros(1,n+1);

t(1) = 0;
s(1) = S0;

for k=1:n
    t(k+1)=t(k)+dt;
    
    r = randn;
 
    % Alternative: random walk
    
    % if (r>0)
    %    r = 1;
    % else
    %    r = -1;
    % end
    
    s(k+1)=s(k)*exp(mu*dt + r*sig*sqrt(dt));
end

end

