I am trying to implement simple birth death process. Why my code does not work? Any suggestion. Thanks. Cross posted http://community.wolfram.com/groups/-/m/t/1205656
birthDeath[λ_, μ_, initialPopulation_, numOfReaction_] :=
NestList[(
Δt1 = RandomVariate[ExponentialDistribution[λ #]];
Δt2 = RandomVariate[ExponentialDistribution[μ #]];
If[Δt1 < Δt2, {# + 1}, {# - 1}]) &, initialPopulation, numOfReaction]
birthDeath[3, 1, 10, 2]