sde, a C++ code which illustrates the properties of stochastic differential equations and some algorithms for handling them, making graphics files for processing and display by gnuplot, by Desmond Higham.

The code requires access to the QR_SOLVE library as well.

The original version of these routines is available at "".


The computer code and data files made available on this web page are distributed under the MIT license


sde is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

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

BROWNIAN_MOTION_SIMULATION, a C++ code which simulates Brownian motion in an M-dimensional region.

COLORED_NOISE, a C++ code which generates samples of noise obeying a 1/f^alpha power law.

CORRELATION, a C++ code which contains examples of statistical correlation functions.

gnuplot_test, C++ codes which illustrate how a program can write data and command files so that gnuplot can create plots of the program results.

ORNSTEIN_UHLENBECK, a C++ code which approximates solutions of the Ornstein-Uhlenbeck stochastic differential equation (SDE) using the Euler method and the Euler-Maruyama method.

PCE_BURGERS, a C++ code 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 C++ code 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 C++ code which computes a "pink noise" signal obeying a 1/f power law.

QR_SOLVE, a C++ code which computes the least squares solution of a linear system A*x=b.


STOCHASTIC_DIFFUSION, a C++ code which implements several versions of a stochastic diffusivity coefficient.

STOCHASTIC_GRADIENT_ND_NOISE, a MATLAB program which solves an optimization problem involving a functional over a system with stochastic noise.

STOCHASTIC_RK, a C++ code which applies a Runge Kutta (RK) scheme to a stochastic differential equation.


Original MATLAB version by Desmond Higham. C++ version by John Burkardt.


  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:

Last revised on 11 April 2020.