Make a function closure to implement Gillespie's Direct Method sampler for a SPN.

step_DM(S, Sout, haz, maxhaz = 1e+06)

Arguments

S

a stoichiometry Matrix-class object

Sout

an optional matrix to track of event firings

haz

a list of hazard functions

maxhaz

maximum allowable hazard

Value

function closure for use in sim_trajectory_R or sim_trajectory_CSV

Details

The direct method is an exact sampling algorithm; it simulates each event individually. Because of this it may be extremely slow for non-trivial population sizes, and thus should be used to debug and test rather than for serious Monte Carlo simulation.

The design of step_DM is from: Wilkinson, D. J. (2011). Stochastic modeling for systems biology. CRC press

Elements of the N list come from two places: The stoichiometry matrix (S) is generated in spn_S and the hazards (h) come from spn_hazards.

For other samplers, see: step_CLE, step_PTS, step_ODE