Skip to main content

Module RNG

Module RNG 

Source
Expand description

Normal draw generation for Monte Carlo pricing.

Two samplers:

  • Seeded pseudo-random (PCG64): reproducible across runs, with antithetic pairing and moment matching as variance reduction.
  • Low-discrepancy (1-D Sobol, i.e. the van der Corput base-2 sequence) mapped through the inverse normal CDF — near-O(1/n) convergence for terminal-value (single-dimension) simulation.

Multi-dimensional (path-wise) draws use the seeded pseudo-random generator; proper multi-dimensional Sobol with a Brownian bridge is future work.

Structs§

BrownianBridge
Brownian bridge path construction: the first draw fixes the terminal value, subsequent draws fill midpoints by bisection, so low-discrepancy coordinates are spent on the dimensions that matter most. Weights are precomputed once per pricing call and shared across paths.
QmcSequence
Multi-dimensional low-discrepancy sequence: Halton with prime bases and a deterministic Cranley-Patterson rotation per dimension (derived from the seed), mapped to standard normals through the inverse CDF.

Functions§

path_normals
Standard normal draws for one path from its own stream.
path_rng
Deterministic, independent RNG stream for one simulation path — the basis of parallel path generation (each path seeds its own generator, so results are identical regardless of thread scheduling).
pseudo_normal_matrix
paths x steps matrix of seeded pseudo-random standard normals for path-wise simulation. Deterministic per seed.
pseudo_normals
n seeded pseudo-random standard normals with antithetic pairing and moment matching (mean 0, variance 1 exactly). Deterministic per seed.
sobol_normals
n low-discrepancy standard normal draws (1-D Sobol through the inverse normal CDF). Deterministic.