Skip to main content

StochasticProcess

Trait StochasticProcess 

Source
pub trait StochasticProcess {
    type State;
    type Diffusion;
    type BrownianIncrement;

    // Required methods
    fn drift(&self, x: &Self::State, t: f64) -> Self::State;
    fn diffusion(&self, x: &Self::State, t: f64) -> Self::Diffusion;
    fn jump_size<R: Rng + ?Sized>(
        &self,
        _x: &Self::State,
        _t: f64,
        _rng: &mut R,
    ) -> Self::State;
    fn expected_value(&self, x0: &Self::State, t: f64) -> Self::State;
    fn variance(&self, x0: &Self::State, t: f64) -> Self::State;
    fn step<R: Rng + ?Sized>(
        &self,
        x: &Self::State,
        t: f64,
        dt: f64,
        dw: &Self::BrownianIncrement,
        rng: &mut R,
    ) -> Self::State;
    fn generate_increment<R: Rng + ?Sized>(
        &self,
        rng: &mut R,
        dt: f64,
    ) -> Self::BrownianIncrement;
    fn simulate<R: Rng + ?Sized>(
        &self,
        x0: Self::State,
        t0: f64,
        t_end: f64,
        dt: f64,
        rng: &mut R,
    ) -> Vec<(f64, Self::State)>;

    // Provided methods
    fn jump_intensity(&self, _x: &Self::State, _t: f64) -> f64 { ... }
    fn simulate_paths(
        &self,
        x0: Self::State,
        t0: f64,
        t_end: f64,
        dt: f64,
        num_paths: usize,
    ) -> Vec<Vec<(f64, Self::State)>>
       where Self: Sync,
             Self::State: Send + Sync + Clone { ... }
}
Expand description

Trait for stateless stochastic process stepping (SDEs).

Unlike crate::Simulatable which owns its state and is used for batch-parallel simulation, this trait takes state by reference and is designed for use in PDE solvers, BSDE methods, and the market engine’s data source layer.

Required Associated Types§

Required Methods§

Source

fn drift(&self, x: &Self::State, t: f64) -> Self::State

Source

fn diffusion(&self, x: &Self::State, t: f64) -> Self::Diffusion

Source

fn jump_size<R: Rng + ?Sized>( &self, _x: &Self::State, _t: f64, _rng: &mut R, ) -> Self::State

Source

fn expected_value(&self, x0: &Self::State, t: f64) -> Self::State

Source

fn variance(&self, x0: &Self::State, t: f64) -> Self::State

Source

fn step<R: Rng + ?Sized>( &self, x: &Self::State, t: f64, dt: f64, dw: &Self::BrownianIncrement, rng: &mut R, ) -> Self::State

Source

fn generate_increment<R: Rng + ?Sized>( &self, rng: &mut R, dt: f64, ) -> Self::BrownianIncrement

Source

fn simulate<R: Rng + ?Sized>( &self, x0: Self::State, t0: f64, t_end: f64, dt: f64, rng: &mut R, ) -> Vec<(f64, Self::State)>

Provided Methods§

Source

fn jump_intensity(&self, _x: &Self::State, _t: f64) -> f64

Source

fn simulate_paths( &self, x0: Self::State, t0: f64, t_end: f64, dt: f64, num_paths: usize, ) -> Vec<Vec<(f64, Self::State)>>
where Self: Sync, Self::State: Send + Sync + Clone,

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§