stochastic_processes/processes/gbm.rs
1use crate::processes::*;
2
3// TODO: Write test to make sure that OU process has correct distribution.
4
5/// The [Geometric Brownian motion](https://en.wikipedia.org/wiki/Geometric_Brownian_motion) process.
6///
7/// This is a stochastic process given by the following stochastic differential equation:
8/// $$ \textrm{d}x_t = \mu x_t \textrm{d} t + \sigma x_t \textrm{d} W_t $$
9/// where $\theta$, $\mu$, and $\sigma$ are parameters of the process and $W_t$ is a standard Brownian motion.
10
11pub struct GeometricBrownianMotion {
12 /// $\mu$ is the (percentage) drift.
13 pub mu: f32,
14
15 /// $\sigma$ is the (percentage) volatility.
16 pub sigma: f32,
17}
18
19impl GeometricBrownianMotion {
20 /// Create a new Geometric Brownian Motion process.
21 pub fn new(mu: f32, sigma: f32) -> Self {
22 Self { mu, sigma }
23 }
24}
25
26impl StochasticProcess for GeometricBrownianMotion {}
27
28impl AutonomousStochasticProcess for GeometricBrownianMotion {
29 fn drift(&self, x: f32) -> f32 {
30 self.mu * x
31 }
32
33 fn diffusion(&self, x: f32) -> f32 {
34 self.sigma * x
35 }
36}