# ORNSTEIN_UHLENBECK Approximate Solution of a Stochastic Differential Equation

ORNSTEIN_UHLENBECK is a FORTRAN77 library which approximates solutions of the Ornstein-Uhlenbeck stochastic differential equation (SDE) using the Euler method and the Euler-Maruyama method, and creating graphics files for processing by gnuplot.

The Ornstein-Uhlenbeck stochastic differential equation has the form:

```        dx(t) = theta * ( mu - x(t) ) dt + sigma dW,
x(0) = x0.
```
where
• theta is a nonnegative decay rate;
• mu is a mean value for x;
• sigma measures the strength of the stochastic perturbation.
and the equation is to be integrated over the interval [0,tmax].

The starting value x0 represents a deviation from the mean value mu. The decay rate theta determines how fast x(t) will move back towards its mean value. The coefficient sigma determines the relative magnitude of stochastic perturbations.

In general, the solution starts at x0 and over time moves towards the value mu, but experiences random "wobbles" whose size is determined by sigma. Increasing theta makes the solution move towards the mean faster.

### Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

### Languages:

ORNSTEIN_UHLENBECK is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version.

### Related Data and Programs:

BLACK_SCHOLES, a FORTRAN77 library which implements some simple approaches to the Black-Scholes option valuation theory, by Desmond Higham.

BROWNIAN_MOTION_SIMULATION, a FORTRAN77 program which simulates Brownian motion in an M-dimensional region.

COLORED_NOISE, a FORTRAN77 library which generates samples of noise obeying a 1/f^alpha power law.

CORRELATION, a FORTRAN90 library which contains examples of statistical correlation functions.

GNUPLOT, FORTRAN77 programs which illustrate how a program can write data and command files so that gnuplot can create plots of the program results.

PCE_BURGERS, a FORTRAN90 program which defines and solves a version of the time-dependent viscous Burgers equation, with uncertain viscosity, using a polynomial chaos expansion in terms of Hermite polynomials, by Gianluca Iaccarino.

PCE_ODE_HERMITE, a FORTRAN90 program which sets up a simple scalar ODE for exponential decay with an uncertain decay rate, using a polynomial chaos expansion in terms of Hermite polynomials.

PINK_NOISE, a FORTRAN90 library which computes a "pink noise" signal obeying a 1/f power law.

SDE, a FORTRAN77 library which illustrates the properties of stochastic differential equations (SDE's), and common algorithms for their analysis, including the Euler method, the Euler-Maruyama method, and the Milstein method, by Desmond Higham;

STOCHASTIC_RK, a FORTRAN77 library which applies a Runge Kutta (RK) scheme to a stochastic differential equation.

### Reference:

1. Desmond Higham,
An Algorithmic Introduction to Numerical Simulation of Stochastic Differential Equations,
SIAM Review,
Volume 43, Number 3, September 2001, pages 525-546.

### Source Code:

• ou.f, the source code.
• ou.sh, BASH commands to compile the source code.

### Examples and Tests:

OU_EULER is data created by the OU_EULER routine:

OU_EULER_MARUYAMA is data created by the OU_EULER_MARUYAMA routine:

### List of Routines:

• GET_UNIT returns a free FORTRAN unit number.
• OU_EULER applies the Euler method to the Ornstein-Uhlenbeck SDE.
• OU_EULER_MARUYAMA applies Euler-Maruyama to the Ornstein-Uhlenbeck SDE.
• R8_UNIFORM_01 returns a unit pseudorandom R8.
• R8VEC_LINSPACE creates a vector of linearly spaced values.
• R8VEC_NORMAL_01 returns a unit pseudonormal R8VEC.
• R8VEC_UNIFORM_01 returns a unit pseudorandom R8VEC.
• TIMESTAMP prints the current YMDHMS date as a time stamp.

You can go up one level to the FORTRAN77 source codes.

Last revised on 21 January 2013.