% This is a template for a simplest simulator of a differential equation
% Gregor Schoner					Nov 2016

clear;

%%%% model parameters 
alpha=0.5; 
noise_strength=0.01; 

%%%%% numerical parameters and initial conditions
time_step=0.01;                     % integration step size 
N_time_steps=1000;                  % number of time steps 
time=time_step*(1:N_time_steps);    % time interval simulated 
variable=zeros(N_time_steps);       % dynamical variable

%%%% initial condition 
variable(1)= 1;                

%%%% loop over time 
for i_time_step=2:N_time_steps 
    
    %%%% integration step (Euler) 
    right_hand_side_of_equation =- alpha*variable(i_time_step-1); 
    variable(i_time_step) = variable(i_time_step-1) + time_step*right_hand_side_of_equation... 
        + sqrt(time_step)*noise_strength*randn; %0.1

end 

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

%%%% possible sigmoid function applied to "variable"
% beta=5
% 1./(1 + exp(-beta*variable)));
