r_ou: Simulation of an Ornstein-Uhlenbeck process

View source: R/scenarios-fr.R

r_ouR Documentation

Simulation of an Ornstein–Uhlenbeck process

Description

Simulation of trajectories of the Ornstein–Uhlenbeck process \{X_t\}. The process is the solution to the stochastic differential equation

\mathrm{d}X_t = \alpha (X_t - \mu)\mathrm{d}t + \sigma \mathrm{d}W_t,

whose stationary distribution is N(\mu, \sigma^2 / (2 \alpha)), for \alpha, \sigma > 0 and \mu \in R.

Given an initial point x_0 and the evaluation times t_1, \ldots, t_m, a sample trajectory X_{t_1}, \ldots, X_{t_m} can be obtained by sampling the joint Gaussian distribution of (X_{t_1}, \ldots, X_{t_m}).

Usage

r_ou(n, t = seq(0, 1, len = 201), mu = 0, alpha = 1, sigma = 1,
  x0 = rnorm(n, mean = mu, sd = sigma/sqrt(2 * alpha)))

Arguments

n

number of trajectories to sample.

t

evaluation times for the trajectories, a vector.

mu

mean of the process, a scalar.

alpha

strength of the drift, a positive scalar.

sigma

diffusion coefficient, a positive scalar.

x0

a vector of length n giving the initial values of the Ornstein–Uhlenbeck trajectories. By default, n points are sampled from the stationary distribution. If a single scalar is passed, then the same x0 is employed for all the trajectories.

Value

Random trajectories, an fdata object of length n and t as argvals.

Author(s)

Eduardo García-Portugués.

Examples

# Same initial point
plot(r_ou(n = 20, x0 = 5), col = viridisLite::viridis(20))

# Different initial points
plot(r_ou(n = 100, alpha = 2, sigma = 4, x0 = 1:100),
     col = viridisLite::viridis(100))

goffda documentation built on Oct. 14, 2023, 5:08 p.m.