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
39
40
41
42
43
44
45
46
47
%
% Revised 8/16/2018

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;
table1 = [igridsmall', psmall];
table2 = [igridbig', pbig];
save "singleparticle.dat" table1 table2

if (~ strcmp (getenv ('OMIT_PLOTS'), 'true')) % PLOTTING
    subplot(2,1,1)
    plot(table1(:,1), table1(:,2:6))

    subplot(2,1,2)
    plot(table2(:,1), table2(:,2:6))
    % TITLE
end % PLOTTING