ssa.d {GillespieSSA}R Documentation

Direct method (D)

Description

Direct method implementation of the SSA as described by Gillespie (1977). It is usually called from within ssa, but can be invoked directly.

Usage

ssa.d(a = stop("missing propensity vector (a)"), 
     nu = stop("missing state-change matrix (nu)"))

Arguments

a vector of evaluated propensity functions.
nu state-change matrix.

Details

Performs one time step using the Direct method.

Value

A list with two elements, 1) the time leap (tau) and 2) the realized state change vector (nu_j).

References

Gillespie (1977)

See Also

GillespieSSA-package, ssa

Examples

## 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")
}

[Package GillespieSSA version 0.5-3 Index]