Milstein method
{{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 Milstein who first published it in 1974.{{cite journal|first=G. N.|last=Mil'shtein |title=Approximate integration of stochastic differential equations|journal=Teoriya Veroyatnostei i ee Primeneniya|volume=19|issue=3|year=1974| pages=583–588| url =http://www.mathnet.ru/php/archive.phtml?wshow=paper&jrnid=tvp&paperid=2929&option_lang=eng|language=ru}}{{Cite journal | last1 = Mil’shtein | first1 = G. N. | title = Approximate Integration of Stochastic Differential Equations | doi = 10.1137/1119062 | journal = Theory of Probability & Its Applications | volume = 19 | issue = 3 | pages = 557–000 | year = 1975 }}
Description
Consider the autonomous Itō stochastic differential equation:
with initial condition , where denotes the Wiener process, and suppose that we wish to solve this SDE on some interval of time . Then the Milstein approximation to the true solution is the Markov chain defined as follows:
- Partition the interval into equal subintervals of width :
- Set
- Recursively define for by: where denotes the derivative of with respect to and: are independent and identically distributed normal random variables with expected value zero and variance . Then will approximate for , and increasing will yield a better approximation.
Note that when (i.e. the diffusion term does not depend on ) this method is equivalent to the Euler–Maruyama method.
The Milstein scheme has both weak and strong order of convergence which is superior to the Euler–Maruyama method, which in turn has the same weak order of convergence but inferior strong order of convergence .V. Mackevičius, Introduction to Stochastic Analysis, Wiley 2011
Intuitive derivation
For this derivation, we will only look at geometric Brownian motion (GBM), the stochastic differential equation of which is given by:
with real constants and . Using Itō's lemma we get:
Thus, the solution to the GBM SDE is:
\begin{align}
X_{t+\Delta t}&=X_t\exp\left\{\int_t^{t+\Delta t}\left(\mu-\frac{1}{2}\sigma^2\right)\mathrm{d}t+\int_t^{t+\Delta t}\sigma\mathrm{d}W_u\right\} \\
&\approx X_t\left(1+\mu\Delta t-\frac{1}{2} \sigma^2\Delta t+\sigma\Delta W_t+\frac{1}{2}\sigma^2(\Delta W_t)^2\right) \\
&= X_t + a(X_t)\Delta t+b(X_t)\Delta W_t+\frac{1}{2}b(X_t)b'(X_t)((\Delta W_t)^2-\Delta t)
\end{align}
where
The numerical solution is presented in the graphic for three different trajectories.Umberto Picchini, SDE Toolbox: simulation and estimation of stochastic differential equations with Matlab. http://sdetoolbox.sourceforge.net/
= Computer implementation =
The following Python code implements the Milstein method and uses it to solve the SDE describing geometric Brownian motion defined by
dY_t= \mu Y \, {\mathrm d}t + \sigma Y \, {\mathrm d}W_t \\
Y_0=Y_\text{init}
\end{cases}
- -*- coding: utf-8 -*-
- Milstein Method
import numpy as np
import matplotlib.pyplot as plt
class Model:
"""Stochastic model constants."""
mu = 3
sigma = 1
def dW(dt):
"""Random sample normal distribution."""
return np.random.normal(loc=0.0, scale=np.sqrt(dt))
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.mu * y * DT + \
Model.sigma * y * dw + \
(Model.sigma**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
{{Reflist}}
Further reading
- {{cite book | author=Kloeden, P.E., & Platen, E. | title=Numerical Solution of Stochastic Differential Equations | publisher=Springer, Berlin | year=1999 | isbn=3-540-54062-8 }}