Learn R Programming

Sim.DiffProc (version 2.8)

rsde1d: Random Number Generators for 1-Dim SDE

Description

The (S3) generic function rsde1d for simulate random number generators to generate 1-dim sde.

Usage

rsde1d(N, ...)
## S3 method for class 'default':
rsde1d(N = 1000, M = 100, x0 = 0, t0 = 0, T = 1, Dt, tau = 0.5, 
   drift, diffusion, alpha = 0.5, mu = 0.5,type = c("ito", "str"), 
   method = c("euler", "milstein", "predcorr", "smilstein", "taylor",
   "heun", "rk1", "rk2", "rk3"), ...)
   
## S3 method for class 'rsde1d':
summary(object, \dots)
## S3 method for class 'rsde1d':
mean(x, \dots)
## S3 method for class 'rsde1d':
median(x, \dots)
## S3 method for class 'rsde1d':
quantile(x, \dots)
## S3 method for class 'rsde1d':
kurtosis(x, \dots)
## S3 method for class 'rsde1d':
skewness(x, \dots)
## S3 method for class 'rsde1d':
moment(x, order = 2, \dots)
## S3 method for class 'rsde1d':
bconfint(x, level=0.95, \dots)
## S3 method for class 'rsde1d':
plot(x, \dots)

Arguments

N
size of sde.
M
number of random numbers to be geneated.
x0
initial value of the process at time t0.
t0
initial time.
T
final time.
Dt
time step of the simulation (discretization). If it is missing a default $\Delta t = \frac{T-t_{0}}{N}$.
tau
moment (time) between t0 and T. Random number generated at time=tau.
drift
drift coefficient: an expression of two variables t and x.
diffusion
diffusion coefficient: an expression of two variables t and x.
alpha, mu
weight of the predictor-corrector scheme; the default alpha = 0.5 and mu = 0.5.
type
sde of the type Ito or Stratonovich.
method
numerical methods of simulation, the default method = "euler"; see snssde1d.
x, object
an object inheriting from class "rsde1d".
order
order of moment.
level
the confidence level required.
...
further arguments for (non-default) methods.

Value

  • rsde1d returns an object inheriting from class "rsde1d".
  • xa vector of random numbers of 1-dim sde realize at time $t=\tau$.

newcommand

\CRANpkg

href

http://CRAN.R-project.org/package=#1

pkg

#1

Details

The function rsde1d returns a random variable $x_{\tau}$ realize at time $t=\tau$ defined by : $$x_{ \tau } = { t \geq 0 ; x = X_{ \tau } }$$ with $\tau$ is a fixed time between t0 and T.

See Also

rsde2d and rsde3d simulation RNs in sde 2 and 3-dim. rng random number generators in yuima package. rcBS, rcCIR, rcOU and rsOU in package sde.

Examples

Run this code
## Example 1: Ito sde
## dX(t) = 2*(3-X(t)) *dt + dW(t)

f <- expression( 4*(2-x) )
g <- expression( 0.2 )
res <- rsde1d(drift=f,diffusion=g,tau=1.75,T=2)
res
summary(res)
plot(res,pos=7,cex=1)
dev.new()
plot(density(res$x))

## Example 2: Stratonovich sde
## dX(t) = (-2*(X(t)<=0)+2*(X(t)>=0)) *dt + 0.5 o dW(t)

f <- expression(-2*(x<=0)+2*(x>=0))
g <- expression(0.5)
res1 <- rsde1d(drift=f,diffusion=g,tau=0.95123,type="str")
res1
summary(res1)
plot(res1,pos=3,cex=1)
dev.new()
plot(density(res1$x))

Run the code above in your browser using DataLab