discretise: Discretise output from a discrete event simulation algorithm

View source: R/gillespie.R

discretiseR Documentation

Discretise output from a discrete event simulation algorithm

Description

This function discretise output from a discrete event simulation algorithm such as gillespie onto a regular time grid, and returns the results as an R ts object.

Usage

discretise(out, dt=1, start=0)

Arguments

out

A list containing discrete event simulation output in the form of that produced by gillespie.

dt

The time step required for the output of the discretisation process. Defaults to one time unit.

start

The start time for the output. Defaults to zero.

Value

An R ts object containing the discretised output.

See Also

simpleEuler, rdiff, gillespie, gillespied, ts

Examples

# load LV model
data(spnModels)
# simulate a realisation of the process and plot it
out = gillespie(LV,10000)
op=par(mfrow=c(2,2))
plot(stepfun(out$t,out$x[,1]),pch="")
plot(stepfun(out$t,out$x[,2]),pch="")
plot(out$x,type="l")

# use the "discretise" function to map it to an R "ts" object
plot(discretise(out,dt=0.01),plot.type="single",lty=c(1,2))
par(op)

smfsb documentation built on Jan. 13, 2024, 3:02 a.m.