Numerical experiments, Tips, Tricks and Gotchas
Brownian Motion and Geometric Brownian Motion
Brownian motion
Brownian Motion or the Wiener process is an idealized continuous-time
stochastic process, which models many real processes in physics, chemistry,
finances, etc [1]. One can see a random "dance" of Brownian
particles with a magnifying glass. More details can be seen with a
microscope. But with further zooming, one can see that the particles
fly freely between their collision with molecules . The randomness
ends on this time (and space) scale. Unlike the real diffusion, the
Wiener process remain stochastic at arbitrarily small scales.
Brownian motion stochastic differential equation
The Brownian motion is described by the following stochastic differential
equation (SDE):
\begin{equation}
dX_{t}=\sigma dW_{t}\label{eq:BrM}
\end{equation}
Here $W_{t}$ is the Wiener process and $\sigma$ is the diffusion coefficient. The solution is well known:
\[
X_{t}\sim\mathit{\mathcal{N}}(0,\sigma^{2}t)
\]
where $\mathit{\mathcal{N}}(\mu, v)$ is the normal or the
Gaussian variable with mean $\mu$ and variance $v$.
Simulating Brownian motion
The usual recipe for simulation of the Brownian motion is
\begin{equation}
\Delta X=\sigma\Delta W\label{eq:recipe}
\end{equation}
with
\begin{equation}
\Delta W=\sqrt{\Delta t}\,\mathcal{N}(0,1)\label{eq:gauss0}
\end{equation}
where $\mathcal{N}(0,1)$ is a normal distribution with zero mean
and unit variance. The variance of $\Delta X$ is
\begin{equation}
\left\langle \Delta X^{2}\right\rangle =\sigma^{2}\Delta t\label{eq:var1}
\end{equation}
Simulation with random walk
Now we use the scaling property and divide $\Delta t$ in $n$ intervals
of size $\tau$:
\begin{equation}
\Delta t=n\tau\label{eq:Dt}
\end{equation}
Then we replace $\Delta W$ with a random walk with steps $h_{i}=\pm h$:
\begin{equation}
\Delta W=\sum_{i=1}^{n}h_{i}\label{eq:walk}
\end{equation}
Now the variance of $\Delta X$ is
\begin{equation}
\left\langle \Delta X^{2}\right\rangle =\sum_{i,j=1}^{n}\left\langle h_{i}h_{j}\right\rangle =nh^{2}=\sigma^{2}\Delta t\frac{h^{2}}{\tau}\label{eq:var2}
\end{equation}
Here we used Eq. (\ref{eq:Dt}) and the fact that the random walk
steps are uncorrelated
\[
\left\langle h_{i}h_{j}\right\rangle =\delta_{i,j}h^{2}
\]
Comparing (\ref{eq:var1}) and (\ref{eq:var2}) we get the relation
between the time and space steps:
\begin{equation}
\tau=h^{2}\label{eq:tauh2}
\end{equation}
Note that the distribution of distances (\ref{eq:walk}) follows the
binomial distribution but it converges to the normal distribution
at large $n$ according to the central limit theorem (CLT). Eq. (\ref{eq:recipe})
with $\Delta W$ (\ref{eq:walk}) and condition (\ref{eq:tauh2})
can be used directly for Brownian motion simulations. However $\Delta W$
(\ref{eq:gauss0}) does not rely on CLT and allows large steps.
Brownian motion with drift
The Eq. (\ref{eq:BrM}) can be easy generalized for taking drift into
account:
\begin{equation}
dX_{t}=\mu dt+\sigma dW_{t}\label{eq:BrMdr}
\end{equation}
The solution is also known:
\begin{equation}
X_{t}\sim\mathit{\mathcal{N}}(\mu t,\sigma^{2}t)\label{eq:gauss}
\end{equation}
The simulation formula
\begin{equation}
\Delta X=\mu\Delta t+\sigma\Delta W\label{eq:recepemu}
\end{equation}
Here both (\ref{eq:gauss0}) and (\ref{eq:walk}) can be used for
$\Delta W$ .
Geometric Brownian motion
Geometric Brownian motion with drift is described by the following
stochastic differential equation:
\begin{equation}
dS_{t}=\mu S_{t}dt+\sigma S_{t}dW_{t}\label{eq:GBM}
\end{equation}
To find the solution for (\ref{eq:GBM}) we consider a small difference
$\Delta S=S(\Delta t)-S(0)$ . We again use Eq. (\ref{eq:Dt}) so
that
\begin{eqnarray*}
S_{0} & = & S(0)\\
S_{1} & = & S(\tau)\\
\cdots & \cdot & \cdots\\
S_{n} & = & S(n\tau)=S(\Delta t)
\end{eqnarray*}
After the fist step
\begin{eqnarray*}
S_{1} & = & S_{0}+\mu S_{0}\tau+\sigma S_{0}h_{1}\\
& = & S_{0}\left(1+\mu\tau+\sigma h_{1}\right)
\end{eqnarray*}
After $n$ steps
\begin{equation}
S(\Delta t)=S_{0}\prod_{i=1}^{n}\left(1+\mu\tau+\sigma h_{i}\right)\label{eq:SDt}
\end{equation}
This expression is sufficient for the simulation of the geometric
Brownian motion.
The logarithm version of the equation
Now we take logarithm of the both sides of Eq. (\ref{eq:SDt})
\begin{equation}
ln\, S(\Delta t)=ln\, S_{0}+ln\left[\prod_{i=1}^{n}\left(1+\mu\tau+\sigma h_{i}\right)\right]\label{eq:lnSDt}
\end{equation}
or
\[
\Delta ln\, S\equiv ln\, S(\Delta t)-ln\, S(0)=\sum_{i=1}^{n}ln\left(1+\mu\tau+\sigma h_{i}\right)
\]
Using the expansion
\[
ln(1+x)\approx x-\frac{x^{2}}{2}
\]
for $x\ll1$ we get
\begin{eqnarray*}
\Delta ln\, S & \approx & \sum_{i=1}^{n}\left[\left(\mu\tau+\sigma h_{i}\right)-\frac{1}{2}\left(\mu\tau+\sigma h_{i}\right)^{2}\right]\\
& = & \sum_{i=1}^{n}\left[\mu\tau+\sigma h_{i}-\frac{\sigma^{2}h^{2}}{2}-\mu\tau\sigma h_{i}-\frac{\mu^{2}\tau^{2}}{2}\right]\\
& = & \mu n\tau+\sigma\sum_{i=1}^{n}h_{i}-\frac{\sigma^{2}n\, h^{2}}{2}-\sigma\mu\tau\sum_{i=1}^{n}h_{i}-\frac{\mu^{2}n\,\tau^{2}}{2}
\end{eqnarray*}
Taking into account (\ref{eq:Dt}, \ref{eq:walk}) we get
\[
\Delta ln\, S=\mu\Delta t+\sigma\Delta W-\frac{\sigma^{2}}{2}\Delta t-\frac{\sigma\mu\Delta t\Delta W}{n}-\frac{\mu^{2}(\Delta t)^{2}}{2n}
\]
The last two terms are of higher order and can be omitted:
\begin{equation}
\Delta ln\, S\approx\left(\mu-\frac{\sigma^{2}}{2}\right)\Delta t+\sigma\Delta W\label{eq:DlnS}
\end{equation}
Note that both that terms tend to zero when $n\rightarrow\infty$
. The above equation (\ref{eq:DlnS}) with $\Delta W$ (\ref{eq:walk})
can be used for the simulation of geometric Brownian motion.
SDE and Ito's lemma
Turing from differences (\ref{eq:DlnS}) to differentials we get this
SDE for $X=ln(S)$
\begin{equation}
dX_{t}=\left(\mu-\frac{\sigma^{2}}{2}\right)dt+\sigma dW_{t}\label{eq:DlnSDt}
\end{equation}
Note that Ito's lemma (the term $-\frac{1}{2}\sigma^{2}dt$) is
automatically taken into account. Eq. (\ref{eq:DlnSDt}) is actually
Brownian motion (\ref{eq:BrMdr}) with modified drift. Therefore the
solution for $X$ is (\ref{eq:gauss}).
References
- Gardiner C. W., Handbook of Stochastic Methods for Physics, Chemistry and
the Natural Science, Berlin: Springer-Verlag, 1983.