Expand description
SDE (Stochastic Differential Equation) solvers for Numra.
This crate provides methods for solving stochastic differential equations of the form:
dX(t) = f(t, X) dt + g(t, X) dW(t)where f is the drift, g is the diffusion, and W(t) is a Wiener process.
§Solvers
EulerMaruyama- Simple fixed-step solver (strong order 0.5)Milstein- Higher order solver (strong order 1.0)Sra1- Adaptive strong order 1.5 methodSra2- Adaptive weak order 2.0 method
§Example
use numra_sde::{SdeSystem, EulerMaruyama, SdeSolver, SdeOptions};
// Geometric Brownian Motion: dS = μS dt + σS dW
struct GBM { mu: f64, sigma: f64 }
impl SdeSystem<f64> for GBM {
fn dim(&self) -> usize { 1 }
fn drift(&self, _t: f64, x: &[f64], f: &mut [f64]) {
f[0] = self.mu * x[0];
}
fn diffusion(&self, _t: f64, x: &[f64], g: &mut [f64]) {
g[0] = self.sigma * x[0];
}
}
let gbm = GBM { mu: 0.05, sigma: 0.2 };
let opts = SdeOptions::default().dt(0.01);
let result = EulerMaruyama::solve(&gbm, 0.0, 1.0, &[100.0], &opts, None);
assert!(result.is_ok());Author: Moussa Leblouba Date: 2 February 2026 Modified: 2 May 2026
Re-exports§
pub use wiener::create_wiener;pub use wiener::WienerIncrement;pub use wiener::WienerProcess;
Modules§
- wiener
- Wiener process (Brownian motion) generator.
Structs§
- Ensemble
Result - Result of ensemble simulation.
- Ensemble
Runner - Ensemble runner for parallel Monte Carlo simulations.
- Ensemble
Stats - Statistics computed from an ensemble of trajectories.
- Euler
Maruyama - Euler-Maruyama SDE solver.
- Milstein
- Milstein SDE solver.
- Percentiles
- Common percentiles.
- Running
Stats - Running statistics using Welford’s online algorithm.
- SdeOptions
- Options for SDE solvers.
- SdeResult
- Result of SDE integration.
- Sra1
- SRA1 - Adaptive strong order 1.0-1.5 method.
- Sra2
- SRA2 - Adaptive weak order 2.0 method.
Enums§
- Noise
Type - Type of noise in the SDE.
Traits§
- Scalar
- A real scalar type suitable for numerical computation.
- SdeSolver
- Trait for SDE solvers.
- SdeSystem
- Trait for stochastic differential equation systems.
Functions§
- mean
- Compute mean of a slice.
- median
- Compute median.
- percentile
- Compute percentile (0-100 scale).
- std
- Compute sample standard deviation.
- variance
- Compute sample variance.