stepAheadWn2D: Multiple simulation of trajectory ends of the WN or MvM...

View source: R/RcppExports.R

stepAheadWn2DR Documentation

Multiple simulation of trajectory ends of the WN or MvM diffusion in 2D

Description

Simulates M trajectories starting from different initial values x0 of the WN or MvM diffusion in 2D, by the Euler method, and returns their ends.

Usage

stepAheadWn2D(x0, mu, A, sigma, rho = 0, M = 100L, N = 100L,
  delta = 0.01, type = 1L, maxK = 2L, expTrc = 30)

Arguments

x0

matrix of size c(nx0, 2) giving the initial points.

mu

a vector of length 2 giving the mean.

A

drift matrix of size c(2, 2).

sigma

vector of length 2 containing the square root of the diagonal of \Sigma, the diffusion matrix.

rho

correlation coefficient of \Sigma.

M

number of Monte Carlo replicates.

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.

Value

An array of size c(nx0, 2, M) containing the M trajectory ends for each starting value x0.

Examples

N <- 100
nx0 <- 3
x0 <- seq(-pi, pi, l = nx0 + 1)[-(nx0 + 1)]
x0 <- as.matrix(expand.grid(x0, x0))
nx0 <- nx0^2
set.seed(12345678)
samp1 <- euler2D(x0 = x0, mu = c(0, 0), A = rbind(c(3, 1), 1:2),
                 sigma = c(1, 1), N = N, delta = 0.01, type = 2)
plot(x0[, 1], x0[, 2], xlim = c(-pi, pi), ylim = c(-pi, pi), pch = 16,
     col = rainbow(nx0))
for (i in 1:nx0) linesTorus(samp1[i, 1, ], samp1[i, 2, ],
                           col = rainbow(nx0, alpha = 0.75)[i])
set.seed(12345678)
samp2 <- stepAheadWn2D(x0 = x0, mu = c(0, 0), A = rbind(c(3, 1), 1:2),
                       sigma = c(1, 1), M = 2, N = N, delta = 0.01,
                       type = 2)
points(samp2[, 1, 1], samp2[, 2, 1], pch = 16, col = rainbow(nx0))
samp1[, , N + 1]
samp2[, , 1]

egarpor/sdetorus documentation built on March 4, 2024, 1:23 a.m.