function Figure3_1a

% Matlab code for Figure 3.1(a) in book:
% Radek Erban and Jon Chapman, Stochastic Modelling of Reaction-Diffusion
% Processes, Cambridge University Press, 2019

close all;
randn('state',12);

dt=0.001;
finaltime=1; 

n=finaltime/dt;
numberofrealisations=6;
X=zeros(numberofrealisations,n);
time=[0:dt:finaltime];

for i=1:numberofrealisations
    dX = sqrt(dt)*randn(1,n);   
    X(i,:)=cumsum(dX(1,:));             
end

figure(1);
set(gca,'Fontsize',18);
plot(time,[0,X(1,:)],'r');   
hold on;
plot(time,[0,X(2,:)],'g');   
plot(time,[0,X(3,:)],'c');   
plot(time,[0,X(4,:)],'b');   
plot(time,[0,X(5,:)],'m');   
plot(time,[0,X(6,:)],'Color',[0.9 0.9 0]);  
line([0 1],[0 0],'Linewidth',2,'Linestyle','--','Color','k');
xlabel('$t$','interpreter','latex');
ylabel('$X$','interpreter','latex');
set(get(gca,'ylabel'),'rotation',0);
axis([0 1 -1.8 1.8]);
set(gca,'Fontsize',18);

