Learn R Programming

fdars (version 0.3.3)

r.ou: Generate Ornstein-Uhlenbeck Process

Description

Simulate sample paths from an Ornstein-Uhlenbeck process using the Euler-Maruyama discretization scheme.

Usage

r.ou(n, t, mu = 0, theta = 1, sigma = 1, x0 = 0, seed = NULL)

Value

An fdata object containing the simulated paths.

Arguments

n

Number of sample paths to generate.

t

Evaluation points (numeric vector).

mu

Long-term mean (default 0).

theta

Mean reversion rate (default 1).

sigma

Volatility (default 1).

x0

Initial value (default 0).

seed

Optional random seed.

Details

The OU process satisfies the SDE: dX(t) = -theta * X(t) dt + sigma * dW(t)

Examples

Run this code
t <- seq(0, 1, length.out = 100)
ou_data <- r.ou(n = 20, t = t, theta = 2, sigma = 1)
plot(ou_data)

Run the code above in your browser using DataLab