I just did this in class today using @IstvánZachar's GillespieSSA
function from this answer. Load that, then:
ClearAll[n];
reactions = {n -> 2 n, n -> Null};
rates = {b0, d0};
b0 = 3;
d0 = 2;
rates = {b0, d0};
init = <|n -> 10|>;
tmax = 1;
sto = GillespieSSA[reactions, init, rates, {0, tmax}];
ListLinePlot[sto, InterpolationOrder -> 0, PlotRange -> {0, All}]
For fun, here's a version with density-dependent mortality:
ClearAll[n];
reactions = {n -> 2 n, n -> Null, 2 n -> Null};
rates = {b0, d0, d1};
b0 = 3;
d0 = 1;
d1 = 0.01;
rates = {b0, d0, d1};
init = <|n -> 10|>;
tmax = 10;
sto = GillespieSSA[reactions, init, rates, {0, tmax}];
ListLinePlot[sto, InterpolationOrder -> 0, PlotRange -> {0, All}]