fast_sde/models/
ou_process.rs

1// src/models/ou_process.rs
2use super::model::SDEModel;
3use std::f64;
4
5pub struct OuProcess {
6    pub theta: f64,
7    pub mu: f64,
8    pub sigma: f64,
9}
10
11impl OuProcess {
12    pub fn new(theta: f64, mu: f64, sigma: f64) -> Self {
13        OuProcess { theta, mu, sigma }
14    }
15}
16
17impl SDEModel for OuProcess {
18    fn drift(&self, s: f64, _t: f64) -> f64 {
19        self.theta * (self.mu - s)
20    }
21
22    fn diffusion(&self, _s: f64, _t: f64) -> f64 {
23        self.sigma
24    }
25
26    fn diffusion_derivative(&self, _s: f64, _t: f64) -> f64 {
27        0.0 // Derivative of a constant diffusion w.r.t. s is 0
28    }
29
30    fn step_with_dw(&self, s_current: &mut f64, t_current: f64, dt: f64, dw: f64) {
31        *s_current += self.drift(*s_current, t_current) * dt + self.diffusion(*s_current, t_current) * dw;
32    }
33}
34