Skip to main content

StochasticProcess

Trait StochasticProcess 

Source
pub trait StochasticProcess: Sync {
    // Required methods
    fn dim(&self) -> usize;
    fn factors(&self) -> usize;
    fn drift(&self, t: f64, x: &[f64], out: &mut [f64]);
    fn diffusion(&self, t: f64, x: &[f64], out: &mut [f64]);

    // Provided methods
    fn constrain(&self, _x: &mut [f64]) { ... }
    fn evolve(&self, t: f64, x: &[f64], dt: f64, dw: &[f64], out: &mut [f64]) { ... }
}
Expand description

An N-state Itô process driven by M independent Brownian factors: dX_i = a_i(t, X) dt + Σ_j b_ij(t, X) dW_j. Factor correlation is expressed through the rows of the diffusion matrix (its Cholesky structure), so dw always carries independent increments.

Required Methods§

Source

fn dim(&self) -> usize

Number of state variables.

Source

fn factors(&self) -> usize

Number of driving Brownian factors (dw.len()).

Source

fn drift(&self, t: f64, x: &[f64], out: &mut [f64])

Drift vector a(t, x) into out (dim long).

Source

fn diffusion(&self, t: f64, x: &[f64], out: &mut [f64])

Diffusion matrix b(t, x) into out, row-major dim × factors.

Provided Methods§

Source

fn constrain(&self, _x: &mut [f64])

State constraint applied after every step (identity by default).

Source

fn evolve(&self, t: f64, x: &[f64], dt: f64, dw: &[f64], out: &mut [f64])

One Euler-Maruyama step from x into out. The default allocates small scratch buffers; hot loops should override with model-specific stepping (which is also where non-Euler schemes — exact transitions, Heston full-truncation/QE — live, since generic multi-factor Milstein would need Lévy areas).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§