function Figure3_4b

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

close all;
rand('state',10);

load data_Figure3_4b_1.dat;
ys=data_Figure3_4b_1(:,1);
taus=data_Figure3_4b_1(:,2);

load data_Figure3_4b_2.dat;
y=data_Figure3_4b_2(:,1);
tau=data_Figure3_4b_2(:,2);

figure(1);
set(gca,'Fontsize',17);
h1=bar(ys,taus);
set(h1,'FaceColor',[0.88 0.88 0.88]);
hold on;
axis([- 0.5 19 0 400]);
set(gca,'XTick',[0 2 4 6 8 10 12 14 16 18 20]);
set(gca,'YTick',[0 100 200 300 400 500 600 700]);
xlabel('$y$','interpreter','latex');
ylabel('$\tau(y)$ [sec]','interpreter','latex');
plot(y,tau,'r','Linewidth',3);
h3=legend('$\;$stochastic simulation','$\;$integral formula');
set(h3,'interpreter','latex','Fontsize',17,'location','southwest');
set(gca,'Fontsize',17);
