birdepy.simulate.continuous()

birdepy.simulate.continuous(param, model, z0, t_max, k=1, survival=False, seed=None, **options)

Simulation of continuous-time birth-and-death processes at birth and death event times.

Parameters:

param (array_like) – The parameters governing the evolution of the birth-and-death process to be simulated. Array of real elements of size (n,), where ‘n’ is the number of param. These must be in the order given here).

modelstring

Model specifying birth and death rates of process (see here). Should be one of:

  • ‘Verhulst’

  • ‘Ricker’

  • ‘Beverton-Holt’

  • ‘Hassell’

  • ‘MS-S’

  • ‘pure-birth’

  • ‘pure-death’

  • ‘Poisson’

  • ‘linear’

  • ‘linear-migration’

  • ‘M/M/1’

  • ‘M/M/inf’

  • ‘loss-system’

  • ‘custom’

If set to ‘custom’, then kwargs b_rate and d_rate must also be specified. See here for more information.

z0: int or callable

The initial population size for each sample path. If it is a callable it should be a function that has no arguments and returns an int:

z0() -> int

t_maxscalar

The simulation horizon. All events up to and including this time are included in the output.

kint, optional

The number of sample paths to be simulated.

survivalbool, optional

If set to True, then the simulated sample paths are conditioned to have a positive population size at the final observation time. This can greatly increase computation time.

seedint, numpy.random._generator.Generator, optional

If seed is not specified the random numbers are generated according to np.random.default_rng(). If seed is an int, random numbers are generated according to np.random.default_rng(seed). If seed is a Generator, then that object is used. See here for more information.

Returns:

  • jump_times (list) – If n=1 a list containing jump times, generated according to model or according to a birth-and-death process evolving according to b_rate and d_rate. Or if n>= 1, a list of lists where each list corresponds to the jump times from one sample path.

  • pop_sizes (list) – If k=1 a list containing population sizes at the corresponding jump times, generated according to model. Or if k>1, a list of lists where each list corresponds to the population sizes corresponding to jump times from one sample path.

Examples

Simulating a unit rate Poisson process up to a t_max of 5:

import birdepy as bd
jump_times, pop_sizes = bd.simulate.continuous(1,'Poisson', 0, t_max=5)
print(jump_times)
print(pop_sizes)

Outputs:

[0, 0.0664050052043501, 0.48462937097695785, 2.2065719224651157]
[0, 1, 2, 3]

Notes

If you use this function for published work, then please cite [1].

Sample paths are generated using a discrete-event simulation algorithm. See, for example, Algorithm 5.8 in [2].

For a text book treatment on the theory of birth-and-death processes see [3].

References

[View birdepy.simulate.continuous() source code]