stepLVc: A function for advancing the state of a Lotka-Volterra model...

Description Usage Arguments Value See Also Examples

View source: R/stepLVc.R

Description

A function for advancing the state of a Lotka-Volterra model by calling some C code implementing the Gillespie algorithm. The function can be used in conjunction with other functions (such as simTs) for simulating realisations of Lotka-Volterra models. Should be functionally identical to the function obtained by data(spnModels), stepLV=StepGillespie(LV), but much faster.

Usage

1
stepLVc(x0,t0,deltat,th=c(1,0.005,0.6))

Arguments

x0

A vector representing the state of the system at the initial time, t0.

t0

The time corresponding to the initial state, x0.

deltat

The time in advance of the initial time at which the new state is required.

th

A vector of length 3 representing the rate constants associated with the 3 LV reactions. Defaults to c(1,0.005,0.6).

Value

A 2-vector representing the new state of the LV system.

See Also

StepGillespie, spnModels, simTs, simSample

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# load the LV model
data(spnModels)
# create a stepping function
stepLV = StepGillespie(LV)
# step the function
print(stepLV(c(x1=50,x2=100),0,1))
# simulate a realisation of the process and plot it
out = simTs(c(x1=50,x2=100),0,100,0.1,stepLV)
plot(out)
# now use "stepLVc" instead...
out = simTs(c(x1=50,x2=100),0,100,0.1,stepLVc)
plot(out)

smfsb documentation built on May 2, 2019, 5:13 a.m.