Learn R Programming

sdetorus (version 0.1.10)

euler1D: Simulation of trajectories of the WN or vM diffusion in 1D

Description

Simulation of the Wrapped Normal (WN) diffusion or von Mises (vM) diffusion by the Euler method in 1D, for several starting values.

Usage

euler1D(x0, alpha, mu, sigma, N = 100L, delta = 0.01, type = 1L,
  maxK = 2L, expTrc = 30)

Value

A matrix of size c(nx0, N + 1) containing the nx0 discretized trajectories. The first column corresponds to the vector x0.

Arguments

x0

vector of length nx0 giving the initial points.

alpha

drift parameter.

mu

mean parameter. Must be in \([\pi,\pi)\).

sigma

diffusion coefficient.

N

number of discretization steps.

delta

discretization step.

type

integer giving the type of diffusion. Currently, only 1 for WN and 2 for vM are supported.

maxK

maximum absolute value of the windings considered in the computation of the WN.

expTrc

truncation for exponential: exp(x) with x <= -expTrc is set to zero. Defaults to 30.

Examples

Run this code
N <- 100
nx0 <- 20
x0 <- seq(-pi, pi, l = nx0 + 1)[-(nx0 + 1)]
set.seed(12345678)
samp <- euler1D(x0 = x0, mu = 0, alpha = 3, sigma = 1, N = N,
                delta = 0.01, type = 2)
tt <- seq(0, 1, l = N + 1)
plot(rep(0, nx0), x0, pch = 16, col = rainbow(nx0), xlim = c(0, 1))
for (i in 1:nx0) linesCirc(tt, samp[i, ], col = rainbow(nx0)[i])

Run the code above in your browser using DataLab