Figure 10.15:

Probability density for single particle stochastic growth model at different times.

Code for Figure 10.15

Text of the GNU GPL.

main.m


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
tfin = 1;
lambda = 10000;
nsim = tfin*lambda;

igrid = 1:nsim;
nts = 5;
p = zeros(nsim,nts);
tvec = linspace(0.1,0.9,nts);
for i = 1:nts
  tau = tfin*tvec(i);
  logp = -lambda*tau +  (igrid-1)*log(lambda*tau) - gammaln(igrid);
  pbig(:,i) = exp(logp);
end
igridbig = igrid;

lambda = 100;
nsim = tfin*lambda;

igrid = 1:nsim;
nts = 5;
p = zeros(nsim,nts);
tvec = linspace(0.1,0.9,nts);
for i = 1:nts
  tau = tfin*tvec(i);
  logp = -lambda*tau +  (igrid-1)*log(lambda*tau) - gammaln(igrid);
  psmall(:,i) = exp(logp);
end
igridsmall = igrid;

figure(1)
plot(igridsmall, psmall)
table1 = [igridsmall', psmall];

figure(2)
plot(igridbig, pbig)
table2 = [igridbig', pbig];

save "singleparticle.dat" table1 table2