Implemented
Random Number Generation
- Normal distribution
- Uniform distribution
- Exponential distribution
- Poisson distribution
- $\alpha$-stable distribution
GPU Acceleration (CUDA)
- Brownian motion moment calculations
- $\alpha$-stable Lévy process moment calculations
- Ornstein-Uhlenbeck process moment calculations
- $\alpha$-stable random number generation
[!NOTE] DiffusionX uses the high-quality Xoshiro256++ random number generator as the common entropy source across all distributions.
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
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 ;
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 raw and central momentsVisualize: Trait for plotting process trajectories
Extending with Custom Processes
-
Adding a New Continuous Process:
-
Implementing
ContinuousProcesstrait automatically provides- mean
mean - msd
msd - raw moment
raw_moment - central moment
central_moment - first passage time
fpt - occupation time
occupation_time - TAMSD
tamsd - visualization
plot
- mean
Example:
Run the following Cargo command in your project directory:
or add the following line to your Cargo.toml:
[]
= { = "*", = ["io", "visualize"] }
use write_csv;
use ;
/// CIR
Result:
mean: 0.9957644815350275
MSD: 0.7441251895881059
FPT: 0.38
Occupation Time: 4.719999999999995
EATAMSD: 0.6085042089895467
GPU Acceleration
[!NOTE] GPU acceleration requires the
cudafeature and a CUDA-capable GPU.# In your Cargo.toml [] = { = "*", = ["cuda"] }
GPUMoment Trait
The gpu::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 |
Example:
use ;
gpu::stable Module
GPU-accelerated stable distribution random number generation.
| Function | Description |
|---|---|
standard_stable_rands(alpha, beta, len) |
Generate len standard stable random numbers with stability alpha ∈ (0, 2] and skewness beta ∈ [-1, 1] |
Example:
use standard_stable_rands;
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 Lanzhou and to XX.