Learn R Programming

Sim.DiffProc (version 2.7)

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 = 100, M = 10, 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)

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
weight alpha of the predictor-corrector scheme; the default alpha = 0.5.
mu
weight mu of the predictor-corrector scheme; the default 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

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

Examples

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

f <- expression( 2*(3-x) )
g <- expression( 1 )
res1 <- rsde1d(drift=f,diffusion=g,M=50,N=1000,tau=0.5412)
res1
summary(res1)
bconfint(res1,level=0.95)
moment(res1,order=c(2,3,4,5))
plot(density(res1$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)
res2 <- rsde1d(drift=f,diffusion=g,M=50,N=1000,tau=0.981232)
res2
summary(res2)
bconfint(res2,level=0.95)
moment(res2,order=c(2,3,4,5))
plot(density(res2$x))

Run the code above in your browser using DataLab