Note
Go to the end to download the full example code.
Simulation of Brownian motion#
The package provides a class to simulate different types of Brownian motion using the following classe: Brownian. The type of Brownian motion can be standard, geometric or fractional.
Standard Brownian motion#
A standard Brownian motion is a stochastic process define as \(\{X_t\}_{t \geq 0}\). The process has the following properties:
\(\{X_t\}_{t \geq 0}\) is a Gaussian process.
For \(s, t \geq 0\), \(\mathbb{E}(X_t) = 0\) and \(\mathbb{E}(X_sX_t) = \min(s, t)\).
The function \(t \rightarrow X_t\) is continuous with probablity \(1\).
To simulate a standard Brownian motion, you can use the following code:

Geometric Brownian motion#
A geometric Brownian motion is a stochastic process \(\{X_t\}_{t \geq 0}\) in which the logarithm of the randomly varying quantity is a Brownian motion with drift.
The process \(\{X_t\}_{t \geq 0}\) satisfies the following stochastic differential equation:
where \(\{W_t\}_{t \geq 0}\) is a Brownian motion, \(\mu\) is the percentage drift and \(\sigma\) is the percentage volatility.
To simulate a geometric Brownian motion, you can use the following code:

Fractional Brownian motion#
A fractional Brownian motion is a stochastic process \(\{X_t\}_{t \geq 0}\) that generalize Brownian motion. Let \(H \in (0, 1)\) be the Hurst parameter. The process has the following properties:
\(\{X_t\}_{t \geq 0}\) is a Gaussian process.
For \(s, t \geq 0\), \(\mathbb{E}(X_t) = 0\) and \(\mathbb{E}(X_sX_t) = \frac{1}{2}\left(|s|^{2H} + |t|^{2H} - |s - t|^{2H}\right)\).
The function \(t \rightarrow X_t\) is continuous with probablity \(1\).
The value of \(H\) defines the process. If \(H = 1/2\), \(\{X_t\} _{t \geq 0}\) is a Brownian motion. If \(H > 1/2\), the increments of \(\{X_t\}_{t \geq 0}\) are positively correlated. If \(H < 1/2\), the increments of \(\{X_t\}_{t \geq 0}\) are negatively correlated.
To simulate a fractional Brownian motion, you can use the following code:

Total running time of the script: (0 minutes 0.279 seconds)