Message Boards Message Boards

Model the birth death process with delay?

GROUPS:

Hi All,

I would like to implement Birth Death Process with Delay.

Here is the code for Birth Death Process without Delay.

SeedRandom@2
With[{A = 5, initialPop = 10}, sim = NestList[(

      \[CapitalDelta]t = 
       RandomVariate@ExponentialDistribution[A #[[2]]];

      {#[[1]] + \[CapitalDelta]t, #[[2]] + 1}

      ) &, {0, initialPop}, 10]];

ListLinePlot[sim, Epilog -> {Red, PointSize[Medium], Point[sim]}, 
 Frame -> True, PlotTheme -> "Detailed", 
 FrameLabel -> {"Time", "Population"}, ImageSize -> Large, 
 InterpolationOrder -> 0]

enter image description here

I don't know how to implement if there is a delay this process with delay. I would like to extend this for Birth-Death process later.

Here is the algorithm for Birth Death Process with Delay.

enter image description here

Any Suggestion. Cross posted at mathematica.stackexchange.com

POSTED BY: Okkes Dulgerci
Answer
3 months ago

Here is my try. How can I store the values and plot list? Can someone check I am doing right? Probably Reap&Sow is the way to do it. I basically need last list of each row to plot.

Thanks in advance.

    SeedRandom@12;
    x = 1;
    t0 = {RandomVariate@ExponentialDistribution[1 x]};
    td0 = {RandomVariate@GammaDistribution[4, 2]};
    s = t0 + td0;

Should be in different cell.

SeedRandom@12
sim = Do[Print[t = RandomVariate@ExponentialDistribution[1 x];
   td = RandomVariate@GammaDistribution[4, 2];
   time = AppendTo[t0, t];
   Which[

    Total@time < 
     First[Sort@s], {s = 
      Sort[Append[s, Total@time + td]], {Total@time, x}},

    Total@time >= 
     First[Sort@s], {s = 
      Rest[Sort@Append[s, Total@time + td]], {First[Sort@s], x += 1}}

    ]], 20]

{{7.49653,9.45693},{3.92079,1}} {{7.49653,8.0122,9.45693},{4.84659,1}} {{7.49653,8.0122,9.45693,25.0336},{5.13493,1}} {{7.49653,8.0122,9.45693,11.2873,25.0336},{5.24162,1}} {{7.49653,8.0122,9.45693,11.2873,13.0339,25.0336},{5.55033,1}} {{8.0122,9.45693,11.2873,11.3798,13.0339,25.0336},{8.0122,2}} {{8.0122,9.45693,11.2873,11.3798,13.0339,14.9935,25.0336},{7.80638,2}} {{9.45693,11.2873,11.3798,11.4994,13.0339,14.9935,25.0336},{9.45693,3}} {{8.90055,9.45693,11.2873,11.3798,11.4994,13.0339,14.9935,25.0336},{8.06442,3}} {{8.90055,9.45693,11.2873,11.3798,11.4994,13.0339,14.0301,14.9935,25.0336},{8.13769,3}} {{8.90055,9.45693,11.2873,11.3798,11.4994,13.0339,14.0301,14.9935,17.6418,25.0336},{8.23758,3}} {{8.90055,9.45693,11.2873,11.3798,11.4994,13.0339,14.0301,14.9935,15.3168,17.6418,25.0336},{8.59103,3}} {{9.45693,11.2873,11.3798,11.4994,13.0339,14.0301,14.9935,15.3168,17.6418,17.6816,25.0336},{9.45693,4}} {{9.45693,11.2873,11.3798,11.4994,13.0339,14.0301,14.9935,15.3168,17.6418,17.6816,17.9959,25.0336},{9.22169,4}} {{9.45693,11.2873,11.3798,11.4994,13.0339,14.0301,14.5392,14.9935,15.3168,17.6418,17.6816,17.9959,25.0336},{9.33083,4}} {{11.2873,11.3798,11.4994,13.0339,14.0301,14.5392,14.9935,15.3168,16.9029,17.6418,17.6816,17.9959,25.0336},{11.2873,5}} {{11.2873,11.3798,11.4994,13.0339,14.0301,14.5392,14.9935,15.3168,15.3674,16.9029,17.6418,17.6816,17.9959,25.0336},{9.72798,5}} {{11.2873,11.3798,11.4994,13.0339,14.0301,14.5392,14.9935,15.3168,15.3674,16.9029,17.6418,17.6816,17.9959,18.6717,25.0336},{10.0076,5}} {{11.2873,11.3798,11.4994,13.0339,14.0301,14.5392,14.9142,14.9935,15.3168,15.3674,16.9029,17.6418,17.6816,17.9959,18.6717,25.0336},{10.2981,5}} {{11.2873,11.3798,11.4994,13.0339,14.0301,14.5392,14.9142,14.9935,15.3168,15.3674,16.9029,17.6418,17.6816,17.9959,18.6717,25.0336,25.6939},{10.5045,5}}

POSTED BY: Okkes Dulgerci
Answer
3 months ago

Group Abstract Group Abstract