rdiff | R Documentation |
This function simulates a single realisation from a time-homogeneous univariate diffusion process.
rdiff(afun, bfun, x0 = 0, t = 50, dt = 0.01, ...)
afun |
A scalar-valued function representing the infinitesimal
mean (drift) of the diffusion process. The first argument of |
bfun |
A scalar-valued function representing the infinitesimal standard deviation of the process. The first argument of |
x0 |
The initial state of the diffusion process. |
t |
The length of the time interval over which the diffusion process is to be simulated. Defaults to 50 time units. |
dt |
The step size to be used both for the time step of the Euler
integration method and the recording interval for the output. It
would probably be better to have separate parameters for these two
things (see |
... |
Additional arguments will be passed into |
An R ts
object containing the sampled path of the process.
rcfmc
, ts
, StepSDE
, simTs
# simulate a diffusion approximation to an immigration-death process
# infinitesimal mean
afun<-function(x,lambda,mu)
{
lambda-mu*x
}
# infinitesimal standard deviation
bfun<-function(x,lambda,mu)
{
sqrt(lambda+mu*x)
}
# plot a sample path
plot(rdiff(afun,bfun,lambda=1,mu=0.1,t=30))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.