ssa.d {GillespieSSA} | R Documentation |
Direct method implementation of the SSA as described by Gillespie (1977). It is usually called from within ssa
, but can be invoked directly.
ssa.d(a = stop("missing propensity vector (a)"), nu = stop("missing state-change matrix (nu)"))
a |
vector of evaluated propensity functions. |
nu |
state-change matrix. |
Performs one time step using the Direct method.
A list with two elements, 1) the time leap (tau
) and 2) the realized state change vector (nu_j
).
Gillespie (1977)
## Logistic growth model a = function(parms,x){ b <- parms[1] d <- parms[2] K <- parms[3] N <- x[1] return(c(b*N , N*b + (b-d)*N/K)) } parms <- c(2,1,1000,500) x <- 500 nu <- matrix(c(+1, -1),ncol=2) t <- 0 for (i in seq(100)) { out <- ssa.d(a(parms,x),nu) x <- x + out$nu_j t <- t + 1 cat("t:",t,", x:",x,"\n") }