Elio Saade
Note

Ornstein-Uhlenbeck Process

Topics: Stochastic Processes

Definition

The Ornstein-Uhlenbeck process is a stochastic process described though the stochastic differential equation (1):
dxt=−θ(xt−μ)+σ⋅dWtdx_t = -\theta(x_t - \mu) + \sigma \cdot dW_t
Stochasticity comes from the second term σ⋅dWt\sigma \cdot dW_t where WtW_t represents a Weiner process. If we have the second term alone dxt=σ⋅dWtdx_t = \sigma \cdot dW_t, then the process is pure diffusion; its standard deviation grows as square root of time, meaning that xx fluctuates without bounds: σxt=σ(t)\sigma_{x_t}=\sigma \sqrt{(t)} (1).

Ornstein-Uhlenbeck_Pure_Diffusion.png

The first term is deterministic; it represents a restoring force that brings xx back to its mean value μ\mu. Without the second term, dxt=−θ(xt−μ)dx_t = -\theta(x_t - \mu), xx would revert back to μ\mu from any starting position exponentially in time with the relaxation rate set by θ\theta (1).

Ornstein-Uhlenbeck_Deterministic.png

With both terms, we get the Ornstein-Uhlenbeck process: the second term drives the process by generating fluctuations, while the first term tries to suppress the fluctuations (1). The process is called mean-reverting because, over time, it tends to drift towards its mean value (2).

The further xx deviates from the mean, the larger the restoring effect becomes. In other words, the restoring term dominates near μ\mu, while the stochastic term dominates away from μ\mu (1).

Statistical Properties

Ornstein-Uhlenbeck_Statistics.png

The Ornstein-Uhlenbeck is a stationary Gauss-Markov process, which means it is a Gaussian process, a Markov process, and is temporarily homogeneous (2).

The mean and variance of the process are:

mean=<xΔt∣x0>=x0 e−θ Δt+μ (1−e−θ Δt)variance=Var(xΔt∣x0)=σ22θ(1−e−2θ Δt)\begin{align*} & mean = <x_{\Delta t} \vert x_0> = x_0 \, e^{-\theta \, \Delta t} + \mu \, (1 - e^{-\theta \, \Delta t}) \\ \\ & variance = Var( x_{\Delta t} \vert x_0 ) = \frac{\sigma ^2}{2 \theta} (1-e^{-2 \theta\, \Delta t}) \end{align*}

From the exponentials in the mean and variance equations, we can notice that the variance converges to its steady-state value twice as fast as the mean.

Simulation in Python

There are 2 ways to simulate the Ornstein-Uhlenbeck process in Python.

Analytical Solution

Given x0x_0 and Δt\Delta t, we compute the mean and variance then sample xΔtx_{\Delta t} from a Gaussian distribution (3).

First  Iterationmean(x0)=<xΔt∣x0>=x0e−θΔt+μ(1−e−θΔt)Var(xΔt∣x0)=σ22θ(1−e−2θΔt)xΔt∼N(mean(x0),Var)Second  Iterationmean(xΔt)=<x2Δt∣xΔt>=xΔt  e−θΔt+μ(1−e−θΔt)Var(x2Δt∣xΔt)=σ22θ(1−e−2θΔt)xΔt∼N(mean(xΔt),Var)Nth  IterationxNΔt∼N(mean(x(N−1)Δt),Var)N=TtotalΔt\begin{align*} & First\; Iteration \\ \\ & mean(x_0) = <x_{\Delta t} \vert x_0> = x_0 e^{-\theta \Delta t} + \mu \left( 1-e^{-\theta \Delta t} \right) \\ \\ & Var(x_{\Delta t} \vert x_0) = \frac{\sigma ^2}{2 \theta} \left( 1-e^{-2 \theta \Delta t} \right) \\ \\ & x_{\Delta t} \sim \mathcal{N}(mean(x_0), Var) \\ \\ \\ \\ & Second\; Iteration \\ \\ & mean(x_{\Delta t}) = <x_{2 \Delta t} \vert x_{\Delta t}> = x_{\Delta t}\; e^{-\theta \Delta t} + \mu \left( 1-e^{-\theta \Delta t} \right) \\ \\ & Var(x_{2 \Delta t} \vert x_{\Delta t}) = \frac{\sigma ^2}{2 \theta} \left( 1-e^{-2 \theta \Delta t} \right) \\ \\ & x_{\Delta t} \sim \mathcal{N}(mean(x_{\Delta t}), Var) \\ \\ \\ \\ & N^{th}\; Iteration \\ \\ & x_{N \Delta t} \sim \mathcal{N}(mean(x_{(N-1)\Delta t}), Var) \\ \\ & N=\frac{T_{total}}{\Delta t} \end{align*}

Euler-Maruyama Solution

We can simulate the Ornstein-Uhlenbeck process using an alternative numerical integration method called Euler-Maruyama method. It is an approximate procedure to numercally solve stochastic differential equations (3).

dxt=−θ(xt−μ)+σ⋅dWtxt+Δt≈xt−θ  Δt  (xt−μ)+σ  ΔWtwhere    σ  ΔWt∼N(0,σ2Δt)<xt+Δt∣xt>≈xt−θ Δt (xt−μ)Var(xt+Δt∣xt)≈σ2 Δt\begin{align*} & dx_t = -\theta(x_t - \mu) + \sigma \cdot dW_t \\ \\ & x_{t+\Delta t} \approx x_t - \theta \; \Delta t \; (x_t - \mu) + \sigma \; \Delta W_t \\ \\ & where \;\; \sigma \; \Delta W_t \sim \mathcal{N}(0, \sigma^2 \Delta t) \\ \\ & <x_{t+\Delta t} \vert x_t> \approx x_t - \theta \, \Delta t \, (x_t - \mu) \\ \\ & Var(x_{t+\Delta t} \vert x_t) \approx \sigma^2 \, \Delta t \end{align*}

Autocorrelation

Autocorrelation is the degree of similarity of the stochastic variable at different times.

  • with Δt\Delta t small with respect to τ\tau, there is high correlation
  • as Δt\Delta t increases (Δt>0.5τ)(\Delta t > 0.5\tau), correlation decreases

Autocorrelation derivation (1):

<xt,xt′> =∫∫xt xt′ P(xt,xt′) dxt dxt′=∫xt∫xt′ P(xt′∣xt) dxt′  ⋅P(xt) dxt=∫xt <xt∣xt′> P(xt) dxt<xt∣xt′>=xt e−θ (t′−t)=<xt>2  e−θ (t′−t)=σ22θ  e−θ (t′−t)=σ22θ  eΔtτ>0\begin{align*} &<x_t, x_{t'}> \,= \int \int x_t \, x_{t'} \, P(x_t, x_{t'}) \, dx_t \, dx_{t'} \\ \\ & \quad \quad \quad \quad \quad = \int x_t \int x_{t'} \, P(x_{t'} \vert x_t) \, dx_{t'} \; \cdot P(x_t) \, dx_t \\ \\ & \quad \quad \quad \quad \quad = \int x_t \, <x_t \vert x_{t'}> \, P(x_t) \, dx_t \quad \quad \quad\quad \quad \quad \quad <x_t \vert x_{t'}> = x_t \, e^{-\theta \, (t'-t)} \\ \\ & \quad \quad \quad \quad \quad = <x_t>^2 \; e^{-\theta \, (t'-t)} \\ \\ & \quad \quad \quad \quad \quad = \frac{\sigma ^2}{2\theta} \; e^{-\theta \, (t'-t)} = \frac{\sigma ^2}{2\theta} \; e^{\frac{\Delta t}{\tau}} > 0 \end{align*}

The exponential decreases as Δt\Delta t increases, meaning that the autocorrelation decreases as Δt\Delta t increases.

References

  1. https://www.youtube.com/watch?v=vFjW-tSR0IQ
  2. https://en.wikipedia.org/wiki/Ornstein%E2%80%93Uhlenbeck_process
  3. https://www.youtube.com/watch?v=FY4-pf7LT1I

Connections

Direct relationships to this note.