stepLVc {smfsb} | R Documentation |
A function for advancing the state of a Lotka-Volterra model by using the Gillespie algorithm
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
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 |
The time corresponding to the initial state, |
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 |
Value
A 2-vector representing the new state of the LV system.
See Also
StepGillespie
, spnModels
, simTs
, simSample
Examples
# 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)