In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
Let $N(\mu,\sigma^2)$ be a normal distribution. A Wiener process $W(t)$ is the limit of a discrete stocastic process. To construct this process, split the total time $t$ into $n$ small intervals of length $h$: $t=nh$. Then, at each time $t_j=jh$, the change in $W$ will just be normally distributed:
$$ W_{j+1}-W_j = \sqrt{h}Z_j $$where $Z_j \sim N(0,1)$. Finally take $h\rightarrow0$ to make it a continuous process.
Here is a Python function that implements one realization of a Wiener process:
In [31]:
def wiener(maxt, n):
"""Return one realization of a Wiener process with n steps and a max time of t."""
t = np.linspace(0.0,maxt,n)
h = t[1]-t[0]
Z = np.random.normal(0.0,1.0,n)
dW = np.sqrt(h)*Z
W = dW.cumsum()
return t, W
In [48]:
t, W = wiener(1.0,500)
In [49]:
plt.plot(t,W)
Out[49]:
In [ ]: