Milstein method

From HandWiki
Short description: Numerical method for solving stochastic differential equations

In mathematics, the Milstein method is a technique for the approximate numerical solution of a stochastic differential equation. It is named after Grigori N. Milstein who first published it in 1974.[1][2]

Description

Consider the autonomous Itō stochastic differential equation: dXt=a(Xt)dt+b(Xt)dWt with initial condition X0=x0, where Wt stands for the Wiener process, and suppose that we wish to solve this SDE on some interval of time [0,T]. Then the Milstein approximation to the true solution X is the Markov chain Y defined as follows:

  • partition the interval [0,T] into N equal subintervals of width Δt>0: 0=τ0<τ1<<τN=T with τn:=nΔt and Δt=TN
  • set Y0=x0;
  • recursively define Yn for 1nN by: Yn+1=Yn+a(Yn)Δt+b(Yn)ΔWn+12b(Yn)b(Yn)((ΔWn)2Δt) where b denotes the derivative of b(x) with respect to x and: ΔWn=Wτn+1Wτn are independent and identically distributed normal random variables with expected value zero and variance Δt. Then Yn will approximate Xτn for 0nN, and increasing N will yield a better approximation.

Note that when b(Yn)=0, i.e. the diffusion term does not depend on Xt, this method is equivalent to the Euler–Maruyama method.

The Milstein scheme has both weak and strong order of convergence, Δt, which is superior to the Euler–Maruyama method, which in turn has the same weak order of convergence, Δt, but inferior strong order of convergence, Δt.[3]

Intuitive derivation

For this derivation, we will only look at geometric Brownian motion (GBM), the stochastic differential equation of which is given by: dXt=μXdt+σXdWt with real constants μ and σ. Using Itō's lemma we get: dlnXt=(μ12σ2)dt+σdWt

Thus, the solution to the GBM SDE is: Xt+Δt=Xtexp{tt+Δt(μ12σ2)dt+tt+ΔtσdWu}Xt(1+μΔt12σ2Δt+σΔWt+12σ2(ΔWt)2)=Xt+a(Xt)Δt+b(Xt)ΔWt+12b(Xt)b(Xt)((ΔWt)2Δt) where a(x)=μx,b(x)=σx

See numerical solution is presented above for three different trajectories.[4]

Numerical solution for the stochastic differential equation just presented, the drift is twice the diffusion coefficient.

Computer implementation

The following Python code implements the Milstein method and uses it to solve the SDE describing the Geometric Brownian Motion defined by {dYt=μYdt+σYdWtY0=Yinit

# -*- coding: utf-8 -*-
# Milstein Method

import numpy as np
import matplotlib.pyplot as plt


class Model:
    """Stochastic model constants."""
    μ = 3
    σ = 1


def dW(Δt):
    """Random sample normal distribution."""
    return np.random.normal(loc=0.0, scale=np.sqrt(Δt))


def run_simulation():
    """ Return the result of one full simulation."""
    # One second and thousand grid points
    T_INIT = 0
    T_END = 1
    N = 1000 # Compute 1000 grid points
    DT = float(T_END - T_INIT) / N
    TS = np.arange(T_INIT, T_END + DT, DT)

    Y_INIT = 1

    # Vectors to fill
    ys = np.zeros(N + 1)
    ys[0] = Y_INIT
    for i in range(1, TS.size):
        t = (i - 1) * DT
        y = ys[i - 1]
        dw = dW(DT)

        # Sum up terms as in the Milstein method
        ys[i] = y + \
            Model.μ * y * DT + \
            Model.σ * y * dw + \
            (Model.σ**2 / 2) * y * (dw**2 - DT)

    return TS, ys


def plot_simulations(num_sims: int):
    """Plot several simulations in one image."""
    for _ in range(num_sims):
        plt.plot(*run_simulation())

    plt.xlabel("time (s)")
    plt.ylabel("y")
    plt.grid()
    plt.show()


if __name__ == "__main__":
    NUM_SIMS = 2
    plot_simulations(NUM_SIMS)

See also

References

  1. Mil'shtein, G. N. (1974). "Approximate integration of stochastic differential equations" (in ru). Teoriya Veroyatnostei i ee Primeneniya 19 (3): 583–588. http://www.mathnet.ru/php/archive.phtml?wshow=paper&jrnid=tvp&paperid=2929&option_lang=eng. 
  2. Mil’shtein, G. N. (1975). "Approximate Integration of Stochastic Differential Equations". Theory of Probability & Its Applications 19 (3): 557–000. doi:10.1137/1119062. 
  3. V. Mackevičius, Introduction to Stochastic Analysis, Wiley 2011
  4. Umberto Picchini, SDE Toolbox: simulation and estimation of stochastic differential equations with Matlab. http://sdetoolbox.sourceforge.net/

Further reading

  • Kloeden, P.E., & Platen, E. (1999). Numerical Solution of Stochastic Differential Equations. Springer, Berlin. ISBN 3-540-54062-8.