stepAheadWn2D {sdetorus} | R 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 |
mu |
a vector of length |
A |
drift matrix of size |
sigma |
vector of length |
rho |
correlation coefficient of |
M |
number of Monte Carlo replicates. |
N |
number of discretization steps. |
delta |
discretization step. |
type |
integer giving the type of diffusion. Currently, only |
maxK |
maximum absolute value of the windings considered in the computation of the WN. |
expTrc |
truncation for exponential: |
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]