rustyqlib/core/montecarlo/mod.rs
1//! Asset-agnostic Monte Carlo machinery, one concern per file — usable
2//! as a standalone simulation toolkit and consumed by the equity pricers.
3//!
4//! Nothing in this module knows about options, spots or curves: it deals
5//! in uniforms, normals, Brownian increments and estimator statistics,
6//! so rates, FX, commodity or credit simulations plug in the same way
7//! equities do.
8//!
9//! - [`paths`]: the public `sample_paths` API — materialized path
10//! matrices over any process, plus the per-path Brownian increment
11//! source ([`PathDraws`]) the pricing engines share;
12//! - [`process`]: the generic Itô-process / SDE abstraction — drift and
13//! diffusion coefficients live in the process, Euler / Milstein are
14//! written once against them, closed-form transitions and
15//! model-specific schemes are per-process overrides;
16//! - [`rng`]: deterministic pseudo-random generation — SplitMix64 stream
17//! derivation and per-path PCG64 streams (bit-reproducible under any
18//! thread scheduling), plus seeded standard-normal draws;
19//! - [`sobol`]: multi-dimensional **Sobol** low-discrepancy sequences
20//! (Gray-code, direction numbers, optional seeded digital-shift
21//! scrambling), and the 1-D van der Corput normals;
22//! - [`halton`]: Halton sequences with Cranley-Patterson rotation — the
23//! arbitrary-dimension quasi-random fallback;
24//! - [`brownian_bridge`]: Brownian-bridge path construction, so the
25//! best low-discrepancy coordinates carry each path's coarse
26//! structure;
27//! - [`variance_reduction`]: antithetic pairing, moment matching, and
28//! the generic regression-based control-variate estimator;
29//! - [`sampling`]: stratified sampling and Latin hypercube designs;
30//! - [`stats`]: simulation statistics — mean / standard error from
31//! accumulated sums and a Welford running accumulator.
32
33pub mod brownian_bridge;
34pub mod halton;
35pub mod paths;
36pub mod process;
37pub mod rng;
38pub mod sampling;
39pub mod sobol;
40pub mod stats;
41pub mod variance_reduction;
42
43pub use brownian_bridge::BrownianBridge;
44pub use halton::QmcSequence;
45pub use paths::{
46 sample_paths, sample_paths_1d, MultiPaths, PathDraws, Paths, SampleConfig, Sampler,
47};
48pub use process::{DiscretizationScheme, StochasticProcess, StochasticProcess1D};
49pub use rng::{path_normals, path_rng, pseudo_normal_matrix, pseudo_normals, splitmix64};
50pub use sampling::{latin_hypercube, stratified_normals, stratified_uniforms};
51pub use sobol::{sobol_normals, SobolSequence};
52pub use stats::{mean_std_err, RunningStats, SimStats};
53pub use variance_reduction::{control_variate_estimate, moment_match};