Tutorials › Stochastic Calculus › Simulating Ornstein-Uhlenbeck Paths with Exact Transitions

Computational Projects in Stochastic Calculus · Tutorial 598 of 600

Simulating Ornstein-Uhlenbeck Paths with Exact Transitions

Learn to simulate exact Ornstein–Uhlenbeck observations on a time grid and verify their conditional and unconditional moments.

Intermediate 12 min read

What You'll Learn

  • Derive the Ornstein–Uhlenbeck transition by an integrating factor and Ito’s formula.
  • Compute the exact conditional mean, variance, and Gaussian noise for one time step.
  • Implement a grid simulation using independent standard normal draws.
  • Distinguish the weighted Brownian integral from a scaled raw Brownian increment.
  • Check simulated transition moments and identify what finite-sample discrepancies mean.
  • Recognize why exact grid transitions do not produce the continuous path between grid points.

Exact Grid Simulation for an Ornstein–Uhlenbeck Process

The Ornstein–Uhlenbeck (OU) process is a continuous-time model whose drift pulls the state toward a level \(\theta\), while Brownian noise continually perturbs it. A time-stepping method that approximates the drift can introduce discretization error. For this process, the conditional distribution at the next grid point is available exactly, so we can simulate grid observations without that time-discretization error.

Work on a filtered probability space \((\Omega,\mathcal{F},(\mathcal{F}_t)_{t\ge0},\mathbb{P})\) carrying a Brownian motion \(B_t\) relative to \((\mathcal{F}_t)\). Fix \(\kappa>0\), \(\theta\in\mathbb{R}\), and \(\sigma\ge0\). The OU equation is

$$ dX_t=\kappa(\theta-X_t)\,dt+\sigma\,dB_t. $$

Here \(\kappa(\theta-X_t)\) is the drift coefficient and \(\sigma\) is the diffusion coefficient. The formula below applies on a finite time interval. All stochastic integrals in this tutorial are Ito integrals. In particular, each integral with a deterministic exponential integrand has a progressively measurable integrand \(H_s\) satisfying \(\mathbb{E}\int_0^T H_s^2\,ds<\infty\), so it belongs to \(\mathcal{L}^2\).

Deriving the Exact Transition

Let \(t\ge0\) and \(h>0\). Multiplying the equation by the integrating factor \(e^{\kappa t}\) yields an explicit solution over the interval from \(t\) to \(t+h\). To justify the multiplication, apply Ito’s formula to \(f(s,x)=e^{\kappa s}(x-\theta)\). Its derivatives are \(f_s=\kappa e^{\kappa s}(x-\theta)\), \(f_x=e^{\kappa s}\), and \(f_{xx}=0\); hence the Ito correction \(\tfrac12 f_{xx}\sigma^2\,ds\) is zero. Substitution of the SDE gives \(d f(s,X_s)=\sigma e^{\kappa s}\,dB_s\). Integrating this identity and rearranging gives the transition representation.

$$ X_{t+h}=\theta+e^{-\kappa h}(X_t-\theta) +\sigma\int_t^{t+h}e^{-\kappa(t+h-s)}\,dB_s. $$
Theorem: For \(h>0\), conditional on \(\mathcal{F}_t\), the next OU observation is Gaussian with mean \(\theta+e^{-\kappa h}(X_t-\theta)\) and variance \(\dfrac{\sigma^2(1-e^{-2\kappa h})}{2\kappa}\). If \(\sigma=0\), this Gaussian law is understood as the point mass at its mean.

Proof. The integrating-factor calculation above proves the displayed representation. The integrand in its stochastic integral is deterministic, and its squared integral over \([t,t+h]\) is finite. The Ito integral of a deterministic square-integrable function against Brownian motion is Gaussian, with mean zero and variance equal to the integral of the squared function; this standard property follows by approximation by deterministic step functions and the independent Gaussian increments of Brownian motion. The integral uses increments after \(t\), which are independent of \(\mathcal{F}_t\). Its conditional mean is therefore zero, and its conditional variance is

$$ \sigma^2\int_t^{t+h}e^{-2\kappa(t+h-s)}\,ds =\sigma^2\int_0^h e^{-2\kappa u}\,du =\frac{\sigma^2(1-e^{-2\kappa h})}{2\kappa}. $$

Adding the \(\mathcal{F}_t\)-measurable term \(\theta+e^{-\kappa h}(X_t-\theta)\) gives the stated conditional mean and variance. When \(\sigma=0\), the stochastic integral vanishes, so the transition is deterministic. \(\square\)

The formula leads directly to a simulation rule. For a grid \(t_j=jh\), write \(a=e^{-\kappa h}\) and \(v=\sigma^2(1-e^{-2\kappa h})/(2\kappa)\). If \(v>0\), generate independent standard normal variables \(Z_1,Z_2,\ldots\) and set

$$ X_{t_{j+1}}=\theta+a(X_{t_j}-\theta)+\sqrt{v}\,Z_{j+1}. $$

This recursion has the exact transition distribution at every step. The \(Z_{j+1}\) in a Brownian-driven representation is the standardized weighted integral \(\displaystyle \frac{\int_{t_j}^{t_{j+1}}e^{-\kappa(t_{j+1}-s)}\,dB_s}{\sqrt{(1-e^{-2\kappa h})/(2\kappa)}}\) when \(\sigma>0\). These variables are independent standard normals across disjoint steps. They are not, in general, the standardized raw Brownian increments \((B_{t_{j+1}}-B_{t_j})/\sqrt h\): the integral uses a time-varying weight. For simulation of the grid-point law, independent standard normal draws can be used instead; this reproduces the joint distribution of the observations, but does not claim to use the same random variables as a given Brownian path.

1
Set the parameters.
Choose \(\kappa>0\), \(\theta\), \(\sigma\ge0\), the time step \(h>0\), and the starting value \(X_0\).
2
Compute transition constants.
Evaluate \(a=e^{-\kappa h}\) and \(v=\sigma^2(1-e^{-2\kappa h})/(2\kappa)\).
3
Generate each observation.
For each step, draw a fresh independent standard normal \(Z_{j+1}\) and apply the recursion. If \(v=0\), the noise term is zero and no normal draw is needed.

The drift and diffusion coefficients are globally Lipschitz in \(x\), and they satisfy a linear growth bound: \(|\kappa(\theta-x)|\le\kappa|\theta|+\kappa|x|\), while \(|\sigma|\) is constant. The explicit construction above gives a strong solution, meaning a solution built from the specified Brownian motion and initial value. Uniqueness for solutions driven by the same Brownian motion also follows directly: their difference \(D_t\) satisfies \(dD_t=-\kappa D_t\,dt\), so \(D_t=e^{-\kappa t}D_0=0\) when they share the same initial value. A recursion driven by independent normal draws is a way to simulate the grid-point law; it need not be coupled to that particular Brownian path.

Worked Example: One Exact Transition

Take \(\kappa=2\), \(\theta=1\), \(\sigma=3\), \(h=\tfrac12\ln 2\), and current state \(X_t=3\). Find the transition distribution and write the simulation update.

First, \(e^{-\kappa h}=e^{-2(\ln 2/2)}=e^{-\ln 2}=\tfrac12\). The conditional mean is therefore \(1+\tfrac12(3-1)=2\). Also \(e^{-2\kappa h}=e^{-2\ln 2}=\tfrac14\), so the conditional variance is

$$ \frac{3^2(1-\tfrac14)}{2\cdot2} =\frac{9\cdot\tfrac34}{4} =\frac{27}{16}. $$

The standard deviation is \(\sqrt{27/16}=3\sqrt{3}/4\). Thus the next observation has distribution \(N(2,27/16)\), and the exact update is \(X_{t+h}=2+(3\sqrt{3}/4)Z\), where \(Z\) is a standard normal draw independent of the past.

Check: the update has mean \(2+(3\sqrt3/4)\mathbb{E}[Z]=2\). Its variance is \((3\sqrt3/4)^2\operatorname{Var}(Z)=27/16\), as required.

Several Steps and Moment Checks

Because each step has the conditional Gaussian law just derived, repeated application of the recursion produces the correct joint distribution at the grid points. The next example checks the arithmetic along a short simulated path; it does not approximate a continuous path between those points.

Worked Example: A Three-Step Grid Path

Let \(\kappa=1\), \(\theta=0\), \(\sigma=\sqrt2\), \(h=\ln2\), and \(X_0=2\). For an illustrative run, use the standardized inputs \(Z_1=0\), \(Z_2=1\), and \(Z_3=-1\). Compute the three observations.

Here \(a=e^{-\ln2}=\tfrac12\), and the transition variance is \(\frac{2(1-e^{-2\ln2})}{2}=1-\tfrac14=\tfrac34\). Thus the standard deviation is \(\sqrt3/2\), and \(X_{t_{j+1}}=\tfrac12X_{t_j}+(\sqrt3/2)Z_{j+1}\). Step by step,

$$ X_{t_1}=\tfrac12(2)+\tfrac{\sqrt3}{2}(0)=1, \qquad X_{t_2}=\tfrac12+\tfrac{\sqrt3}{2}, $$
$$ X_{t_3}=\tfrac12\left(\tfrac12+\tfrac{\sqrt3}{2}\right)-\tfrac{\sqrt3}{2} =\tfrac14+\tfrac{\sqrt3}{4}-\tfrac{2\sqrt3}{4} =\frac{1-\sqrt3}{4}. $$

Check: substituting \(X_{t_2}\) and \(Z_3=-1\) into the one-step recursion gives \(\tfrac12(\tfrac12+\tfrac{\sqrt3}{2})-\tfrac{\sqrt3}{2}\), which simplifies to the stated \(X_{t_3}\). The chosen inputs are fixed values for checking the update arithmetic, not a claim that an ideal continuous normal draw equals each value with positive probability.

The exact transition also gives moment benchmarks. For deterministic \(X_0=x_0\), the solution at time \(t\) is a deterministic mean plus a centered Gaussian Ito integral. Consequently its mean is \(\theta+e^{-\kappa t}(x_0-\theta)\), and its variance is \(\sigma^2(1-e^{-2\kappa t})/(2\kappa)\). The same expressions apply conditionally over one step, with the current state replacing \(x_0\) and \(h\) replacing \(t\).

Proposition: Suppose \(X_t=x\) is fixed when conditioning on \(\mathcal{F}_t\), and let \(Y=X_{t+h}\). Then \(\mathbb{E}[Y\mid\mathcal{F}_t]=m=\theta+e^{-\kappa h}(x-\theta)\) and \(\mathbb{E}[(Y-m)^2\mid\mathcal{F}_t]=v=\sigma^2(1-e^{-2\kappa h})/(2\kappa)\). For \(N\) independent transition draws \(Y_1,\ldots,Y_N\) from this conditional law, the sample mean has expectation \(m\); the sample variance using divisor \(N\) has expectation \((N-1)v/N\). These statements include \(v=0\).

Proof. The first two identities are the transition theorem. For the sample mean, linearity of expectation gives \(\mathbb{E}[\frac1N\sum_{i=1}^N Y_i\mid\mathcal{F}_t]=m\). For the variance calculation, define \(\bar Y=\frac1N\sum_iY_i\). The identity \(\sum_i(Y_i-\bar Y)^2=\sum_i(Y_i-m)^2-N(\bar Y-m)^2\) follows by expanding both sides and using \(\sum_i(Y_i-m)=N(\bar Y-m)\). The conditional expectation of the first sum is \(Nv\). Independence gives \(\mathbb{E}[(\bar Y-m)^2\mid\mathcal{F}_t]=v/N\), since the cross terms of distinct centered independent draws have expectation zero. Therefore the expected sum of squared deviations from \(\bar Y\) is \(Nv-N(v/N)=(N-1)v\); dividing by \(N\) proves the assertion. If \(v=0\), every draw equals \(m\) almost surely, and both sides of the sample-variance identity are zero. \(\square\)

Worked Example: Checking a Balanced Batch

Take \(\kappa=1\), \(\theta=1\), \(\sigma=2\), \(h=\ln2\), and current state \(X_t=1\). A deterministic unit test for the transition map uses the four standardized inputs \(-1,-1,1,1\). Compute the resulting batch mean and population variance, then compare them with the theoretical moments.

Since \(e^{-h}=\tfrac12\), the conditional mean is \(1+\tfrac12(1-1)=1\). Since \(e^{-2h}=\tfrac14\), the conditional variance is \(\frac{4(1-\tfrac14)}{2}=\tfrac32\), and the standard deviation is \(\sqrt{3/2}\). The four outputs are \(1-\sqrt{3/2},1-\sqrt{3/2},1+\sqrt{3/2},1+\sqrt{3/2}\). Their mean is

$$ \frac{2(1-\sqrt{3/2})+2(1+\sqrt{3/2})}{4} =\frac4{4}=1. $$

Each deviation from the mean has square \(3/2\), so the population variance, using divisor four, is \(\frac{4(3/2)}4=\frac32\). Check: these batch moments match the conditional mean and variance computed from the transition formula. This balanced input is an arithmetic test, not a typical random Monte Carlo batch. In an actual run, independent normal draws generally give sample moments that differ from the theoretical moments; the proposition specifies their expectations, not an exact match for every finite sample.

What Exactness Does—and Does Not—Mean

The word “exact” refers to the distribution of the observations at the selected times. The recursion does not use an Euler approximation to the drift, so it has no time-discretization bias for those grid-point transitions. It does not supply all the intermediate values of the continuous OU path. If a plot needs values between grid points, those values require additional simulation conditional on the endpoints or a finer grid; simply drawing straight lines between observations is only a visual interpolation.

A common error is to replace the weighted integral in the transition with a scaled raw Brownian increment. For example, when \(\kappa=1\) and \(h=\ln2\), the kernel on a step, written with elapsed time \(u\), is \(e^{-(h-u)}\), which is not constant. The correct noise is \(\sigma\int_t^{t+h}e^{-(t+h-s)}\,dB_s\), whose variance is \(\sigma^2(1-e^{-2h})/2\). Replacing it by \(c(B_{t+h}-B_t)\) and matching variances would require \(c^2h=(1-e^{-2h})/2\), but equality of variances does not make the random variables equal. The transition recursion is valid because it uses an independent standard normal with the correct law, not because a raw Brownian increment is the same weighted noise.

QuantityExact transition valueSimulation check
Conditional mean\(\theta+e^{-\kappa h}(X_t-\theta)\)Compare with the batch mean across repeated transitions from the same state.
Conditional variance\(\sigma^2(1-e^{-2\kappa h})/(2\kappa)\)Compare with the batch variance, allowing for finite-sample fluctuation.
Noise couplingA weighted Ito integral in the Brownian representationIndependent standard normals reproduce its law for grid simulation.

Check Your Understanding

Use the transition formula and its hypotheses to answer each question.

  1. For \(\kappa=1\), \(\theta=0\), \(\sigma=1\), and \(h=\ln2\), compute the exact conditional mean and variance when \(X_t=2\).
  2. Explain why a standardized raw Brownian increment need not equal the standardized weighted integral in the transition.
  3. For \(\sigma=0\), write the one-step update and state its conditional variance.
  4. For \(N\) independent transition draws, why is the expected population variance \((N-1)v/N\), rather than \(v\)?
  5. Does an exact grid transition determine the OU path between grid points? Explain what “exact” means here.