pub trait StochasticProcess1D: Sync {
// Required methods
fn drift(&self, t: f64, x: f64) -> f64;
fn diffusion(&self, t: f64, x: f64) -> f64;
// Provided methods
fn diffusion_dx(&self, t: f64, x: f64) -> f64 { ... }
fn exact_step(&self, _t: f64, _x: f64, _dt: f64, _dw: f64) -> Option<f64> { ... }
fn constrain(&self, x: f64) -> f64 { ... }
fn evolve(
&self,
scheme: DiscretizationScheme,
t: f64,
x: f64,
dt: f64,
dw: f64,
) -> f64 { ... }
}Expand description
A scalar Itô process dX = a(t, X) dt + b(t, X) dW.
Implementations are shared across rayon path chunks, hence Sync.
Required Methods§
Provided Methods§
Sourcefn diffusion_dx(&self, t: f64, x: f64) -> f64
fn diffusion_dx(&self, t: f64, x: f64) -> f64
∂b/∂x, the extra coefficient Milstein needs.
Sourcefn exact_step(&self, _t: f64, _x: f64, _dt: f64, _dw: f64) -> Option<f64>
fn exact_step(&self, _t: f64, _x: f64, _dt: f64, _dw: f64) -> Option<f64>
One draw from the closed-form transition X_{t+dt} | X_t = x,
when the process has one. None (the default) makes the Exact
scheme fall back to Euler.
Sourcefn constrain(&self, x: f64) -> f64
fn constrain(&self, x: f64) -> f64
State constraint applied after every step. Identity by default — only processes whose state space is genuinely bounded (lognormal equity at zero, truncated variance) should clamp.
Sourcefn evolve(
&self,
scheme: DiscretizationScheme,
t: f64,
x: f64,
dt: f64,
dw: f64,
) -> f64
fn evolve( &self, scheme: DiscretizationScheme, t: f64, x: f64, dt: f64, dw: f64, ) -> f64
Advance the state by one step of scheme: the generic stepping,
written against drift/diffusion alone. Override only to
exploit model structure (e.g. one volatility lookup shared by the
coefficients, or a scheme the enum cannot express).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".