simplePdmp | R Documentation |
This is a simple example for a piecewise deterministic markov process
defined as pdmpModel
. It is included to the package for
demonstration purposes and is used in some unit tests and function
examples.
simplePdmp
An object of class pdmpModel
.
parms
There are no parameters for this model.
init
There is one continous variable f
with initial value 0
and one discrete variable d
initial value 0.
discStates
The discrete variable d
has codomain {-1, 0, 1}.
dynfunc
The continous variable f
evolves as linear function
f(t) = t
if d = 1
,
as f(t) = -t
if d = -1
and is constant zero if d = 0
.
Its dynamic can therefore be described as \frac{df}{dt} = d
.
jumpfunc
There are two jumptypes. The first jumps from d
to
d - 1
, the second from d
to d + 1
. Both reset f
to zero.
ratefunc
A vector of length two determining the probability of a jump
being of type 1 or 2. If d = -1
, it has value (0, 2)
forcing
the jumptype to be of type 2. The same takes place for d = 1
:
ratefunc
returnes (2, 0)
and the jumptype is therefore always
of type 1. In case d = 0
, ratefunc
returnes (1, 1)
which
leads to a probability of \frac{1}{2}
to have a jumptype of type
1 or 2.
times
The simulations will start at time t = 0
and end at
t = 10
with step length 0.01.
toggleSwitch
for a more sophisticated example of a
pdmpModel
and pdmpModel
for the formal description of the S4 class.
## the code used to generate this model:
simplePdmp <- pdmpModel(
descr = "A simple PDMP",
init = c(f = 0, d = 0),
discStates = list(d = c(-1, 0, 1)),
times = c(from = 0, to = 10, by = 0.01),
dynfunc = function(t, x, parms) c(x["d"], 0),
ratefunc = function(t, x, parms) c(1+x["d"], 1-x["d"]),
jumpfunc = function(t, x, parms, jtype){
c(0, switch(jtype, x["d"]-1, x["d"]+1))
})
## load it and plot a simulation:
data("simplePdmp")
plot(sim(simplePdmp))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.