function Figure3_1c

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

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

dt=0.1;
finaltime=10*60;  % 10 minutes
D=0.0001;         % 10^{-4} mm^2 sec^{-1}

n=finaltime/dt;
numberofrealisations=6;
X=zeros(numberofrealisations,n);
Y=zeros(numberofrealisations,n);

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

Xplot(:,:)=X(:,5:5:n);
Yplot(:,:)=Y(:,5:5:n);

figure(1);
set(gca,'Fontsize',18);
plot([0,Xplot(4,:)],[0,Yplot(4,:)],'Color',[0.9 0.9 0]);   
hold on;
plot([0,Xplot(1,:)],[0,Yplot(1,:)],'m');   
plot([0,Xplot(2,:)],[0,Yplot(2,:)],'c');   
plot([0,Xplot(3,:)],[0,Yplot(3,:)],'g');   
plot([0,Xplot(5,:)],[0,Yplot(5,:)],'b');   
plot([0,Xplot(6,:)],[0,Yplot(6,:)],'r');  
line([-2.5 2.5],[0 0],'Color','k');
line([0 0],[-2.5 2.5],'Color','k');
plot([X(1,n)],[Y(1,n)],'ko','Linewidth',6);   
plot([X(2,n)],[Y(2,n)],'ko','Linewidth',6);   
plot([X(3,n)],[Y(3,n)],'ko','Linewidth',6);   
plot([X(4,n)],[Y(4,n)],'ko','Linewidth',6);   
plot([X(5,n)],[Y(5,n)],'ko','Linewidth',6);   
plot([X(6,n)],[Y(6,n)],'ko','Linewidth',6);  
xlabel('$x$ [mm]','interpreter','latex');
ylabel('$y$ [mm]','interpreter','latex');
set(gca,'XTick',[-0.6 -0.4 -0.2 0 0.2 0.4 0.6]);
set(gca,'YTick',[-0.6 -0.4 -0.2 0 0.2 0.4 0.6]);
axis([-0.7 0.7 -0.7 0.7]);
set(gca,'Fontsize',18);

