function S = StochasticGen(S_init,mu,sigma,dt,max_i)

S(1) =  S_init;

for i = 1:max_i-1
 
    dX(i) = normrnd(0,sqrt(dt));
    dS(i) = sigma*dX(i)*S(i) + mu*dt*S(i);
    S(i+1) = S(i) + dS(i);
    
end