Implemented
Random Number Generation
[!NOTE] DiffusionX uses the high-quality Xoshiro256++ random number generator as the common entropy source across all distributions.
- Normal distribution
- Uniform distribution
- Exponential distribution
- Poisson distribution
- $\alpha$-stable distribution
Stochastic Processes Simulation
- Brownian motion
- $\alpha$-stable Lévy process
- Cauchy process
- $\alpha$-stable subordinator
- Inverse $\alpha$-stable subordinator
- Poisson process
- Fractional Brownian motion
- Continuous-time random walk
- Ornstein-Uhlenbeck process
- Langevin equation
- Generalized Langevin equation
- Subordinated Langevin equation
- Lévy walk
- Birth-death process
- Random walk
- Brownian excursion
- Brownian meander
- Gamma process
- Geometric Brownian motion
- Brownian yet non-Gaussian process
GPU Acceleration (CUDA/Metal)
The acceleration includes moment calculation and random number generation.
- Brownian motion
- $\alpha$-stable Lévy process
- Ornstein-Uhlenbeck process
- $\alpha$-stable distribution
Usage
Random Number Generation
use ;
Stochastic Process Simulation
use ;
Visualization
[!NOTE] The visualization requires the
visualizefeature to be enabled.# In your Cargo.toml [] = { = "*", = ["visualize"] }
use ;
GPU Acceleration
[!NOTE] This requires the
metalorcudafeature to be enabled.# In your Cargo.toml [] = { = "*", = ["cuda"] }
use ;
Architecture and Extensibility
DiffusionX is designed with a trait-based system for high extensibility and performance:
Core Traits
ContinuousProcess: Base trait for continuous stochastic processesPointProcess: Base trait for point processesDiscreteProcess: Base trait for discrete stochastic processesMoment: Trait for statistical moments calculation, including (fractional) raw and central momentsVisualize: Trait for plotting process trajectoriesGPUMoment: Trait for simulating the (fractional) moments in CUDA.
The GPUMoment trait provides GPU-accelerated statistical moment calculations. It is implemented for:
Bm<T>- Brownian MotionOrnsteinUhlenbeck<T>- Ornstein-Uhlenbeck ProcessLevy<T>- Lévy Process
| Method | Description |
|---|---|
mean_gpu(duration, particles, time_step) |
Calculate mean (first raw moment) |
msd_gpu(duration, particles, time_step) |
Calculate mean squared displacement (second central moment) |
raw_moment_gpu(duration, order, particles, time_step) |
Calculate raw moment of integer order |
central_moment_gpu(duration, order, particles, time_step) |
Calculate central moment of integer order |
frac_raw_moment_gpu(duration, order, particles, time_step) |
Calculate raw moment of fractional order |
frac_central_moment_gpu(duration, order, particles, time_step) |
Calculate central moment of fractional order |
Extending with Custom Processes
-
Adding a New Continuous Process:
-
Implementing
ContinuousProcesstrait automatically provides- mean
mean - msd
msd - (fractional) raw moment
raw_moment(frac_raw_moment) - (fractional) central moment
central_moment(frac_central_moment) - first passage time
fpt - occupation time
occupation_time - TAMSD
tamsd - visualization
plot
- mean
The full example implementing the CIR process is here.
Benchmark
Performance benchmark tests compare the Rust, C++, Julia, and Python implementations, which can be found here.
License
Licensed under either of:
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Dedicated to my brief yet unforgettable years in LZU and to XX.