pub struct StochasticDifferentialEquation;Expand description
SDE solver for dX = mu(X,t)dt + sigma(X,t)dW.
Implementations§
Source§impl StochasticDifferentialEquation
impl StochasticDifferentialEquation
Sourcepub fn euler_maruyama<F, G>(
mu: F,
sigma: G,
x0: f64,
t0: f64,
t_end: f64,
n_steps: usize,
seed: u64,
) -> (Vec<f64>, Vec<f64>)
pub fn euler_maruyama<F, G>( mu: F, sigma: G, x0: f64, t0: f64, t_end: f64, n_steps: usize, seed: u64, ) -> (Vec<f64>, Vec<f64>)
Euler-Maruyama scheme: X_{n+1} = X_n + mu(X_n, t_n)*dt + sigma(X_n, t_n)*sqrt(dt)*Z.
Strong order 0.5, weak order 1.0.
Sourcepub fn milstein<F, G, H>(
mu: F,
sigma: G,
sigma_prime: H,
x0: f64,
t0: f64,
t_end: f64,
n_steps: usize,
seed: u64,
) -> (Vec<f64>, Vec<f64>)
pub fn milstein<F, G, H>( mu: F, sigma: G, sigma_prime: H, x0: f64, t0: f64, t_end: f64, n_steps: usize, seed: u64, ) -> (Vec<f64>, Vec<f64>)
Milstein scheme: adds a correction term for higher strong order (1.0).
X_{n+1} = X_n + mudt + sigmadW + 0.5sigmasigma’*(dW^2 - dt). sigma_prime is the derivative of sigma with respect to x.
Sourcepub fn runge_kutta_maruyama<F, G>(
mu: F,
sigma: G,
x0: f64,
t0: f64,
t_end: f64,
n_steps: usize,
seed: u64,
) -> (Vec<f64>, Vec<f64>)
pub fn runge_kutta_maruyama<F, G>( mu: F, sigma: G, x0: f64, t0: f64, t_end: f64, n_steps: usize, seed: u64, ) -> (Vec<f64>, Vec<f64>)
Runge-Kutta (Runge-Kutta-Maruyama) order 1 scheme for Ito SDEs.
Uses a predictor step to estimate the diffusion coefficient more accurately.
Sourcepub fn monte_carlo_paths<F, G>(
mu: F,
sigma: G,
x0: f64,
t0: f64,
t_end: f64,
n_steps: usize,
n_paths: usize,
seed: u64,
) -> Vec<Vec<f64>>
pub fn monte_carlo_paths<F, G>( mu: F, sigma: G, x0: f64, t0: f64, t_end: f64, n_steps: usize, n_paths: usize, seed: u64, ) -> Vec<Vec<f64>>
Simulate multiple paths (Monte Carlo ensemble).
Returns a matrix of shape (n_paths, n_steps+1).
Sourcepub fn strong_error_estimate<F, G>(
mu: F,
sigma: G,
x0: f64,
t0: f64,
t_end: f64,
seed: u64,
n_steps_coarse: usize,
n_steps_fine: usize,
) -> f64
pub fn strong_error_estimate<F, G>( mu: F, sigma: G, x0: f64, t0: f64, t_end: f64, seed: u64, n_steps_coarse: usize, n_steps_fine: usize, ) -> f64
Compute the strong order of convergence from a reference solution.
Returns the estimated strong error at the terminal time.
Sourcepub fn weak_order_estimate<F, G, H>(
mu: F,
sigma: G,
functional: H,
x0: f64,
t0: f64,
t_end: f64,
n_steps: usize,
n_paths: usize,
seed: u64,
) -> f64
pub fn weak_order_estimate<F, G, H>( mu: F, sigma: G, functional: H, x0: f64, t0: f64, t_end: f64, n_steps: usize, n_paths: usize, seed: u64, ) -> f64
Compute the weak order of convergence via expected value of a functional.
Returns E[f(X(T))] estimated from n_paths Monte Carlo paths.
Auto Trait Implementations§
impl Freeze for StochasticDifferentialEquation
impl RefUnwindSafe for StochasticDifferentialEquation
impl Send for StochasticDifferentialEquation
impl Sync for StochasticDifferentialEquation
impl Unpin for StochasticDifferentialEquation
impl UnsafeUnpin for StochasticDifferentialEquation
impl UnwindSafe for StochasticDifferentialEquation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.