Skip to main content

Module quasirandom

Module quasirandom 

Source
Expand description

Quasi-random low-discrepancy sequences (feature quasirandom). Quasi-random (low-discrepancy) sequences.

Quasi-random sequences cover the unit cube [0, 1)^D more evenly than uniform PRNG draws - variance for Monte Carlo integration scales O((log n)^d / n) rather than O(1/√n). They’re standard tools for ray-tracing, financial simulation, and high-dimensional numerical integration.

Three constructions are shipped:

  • VanDerCorputSequence
    • 1-D, any prime base.
  • HaltonSequence
    • multi-dim, Van der Corput across the first primes. Supports up to 32 dimensions.
  • SobolSequence
    • multi-dim, uses precomputed direction numbers. Supports up to 6 dimensions out of the box; the Joe-Kuo D6 file would extend this past 21 000.

These are not PRNGs and live alongside, not inside, crate::Random. Use a PRNG when you want unpredictability; use a quasi-random sequence when you want even coverage.

Structs§

HaltonSequence
Multi-dimensional Halton sequence - Van der Corput across the first HALTON_MAX_DIM primes. Discrepancy is excellent for dimensions up to ~10; beyond that consider SobolSequence or scrambled Halton.
SobolSequence
Multi-dimensional Sobol sequence (Bratley-Fox 1988 starter set, dimensions 1–6). For higher-dimensional uses, switch to a Joe-Kuo D6 direction-number table (out of scope here).
VanDerCorputSequence
1-D Van der Corput sequence in a given prime base. Each step reverses the index’s base-b digit expansion and reads it as a fraction in [0, 1).

Constants§

HALTON_MAX_DIM
Maximum number of dimensions supported by HaltonSequence.
SOBOL_MAX_DIM
Maximum number of dimensions SobolSequence supports with the shipped direction-number table.