% Forward stochastic Euler simple simulator 
% Gregor Schoner					Apr 2021
clear;

%%%% model parameters 
tau = 10; 
noise_strength =0.01; 

%%%% time 
time_step=0.01;                     % integration step size 
T_final=100;
time=1:time_step:T_final; 
N_time_steps=size(time,2); 

%%%% initial condition 
variable=zeros(N_time_steps);    % dynamical variable
variable(1)= 1.0;   
            
%%%% loop over time 
for i_time_step=2:N_time_steps 
    
    right_hand_side_of_equation = - variable(i_time_step-1)/tau ; 
    
    variable(i_time_step) ...
        = variable(i_time_step-1) ...
        + time_step*right_hand_side_of_equation... 
        + sqrt(time_step)*noise_strength*randn;

end 

%%%% display solution 
figure;
plot(time, variable); 
title(' solution as function of time')