rTrajOu: Simulation of trajectories for the univariate OU diffusion

View source: R/OU.R

rTrajOuR Documentation

Simulation of trajectories for the univariate OU diffusion

Description

Simulation of trajectories of the univariate Ornstein–Uhlenbeck (OU) diffusion

dX_t=\alpha(\mu - X_t)dt+\sigma dW_t, X_0=x_0

using the exact transition probability density.

Usage

rTrajOu(x0, alpha, mu, sigma, N = 100, delta = 0.001)

Arguments

x0

initial point.

alpha

strength of the drift.

mu

unconditional mean of the diffusion.

sigma

diffusion coefficient.

N

number of discretization steps in the resulting trajectory.

delta

time discretization step.

Details

The law of the discretized trajectory is a multivariate normal with mean meantOu and covariance matrix covstOu. See rTrajMou for the multivariate case (less efficient for dimension one).

Value

A vector of length N + 1 containing x0 in the first entry and the exact discretized trajectory on the remaining elements.

Examples

isRStudio <- identical(.Platform$GUI, "RStudio")
if (isRStudio) {
  manipulate::manipulate({
   set.seed(345678);
   plot(seq(0, N * delta, by = delta), rTrajOu(x0 = 0, alpha = alpha, mu = 0,
        sigma = sigma, N = N, delta = delta), ylim = c(-4, 4), type = "l",
        ylab = expression(X[t]), xlab = "t")
   }, delta = manipulate::slider(0.01, 5.01, step = 0.1),
   N = manipulate::slider(10, 500, step = 10, initial = 200),
   alpha = manipulate::slider(0.01, 5, step = 0.1, initial = 1),
   sigma = manipulate::slider(0.01, 5, step = 0.1, initial = 1))
}

sdetorus documentation built on Aug. 21, 2023, 1:08 a.m.

Related to rTrajOu in sdetorus...