# Algorithm notes and provenance

## Sobol direction numbers

`lib/qmc/sobol.mbt` contains a self-contained MoonBit implementation of the
Sobol generator for up to 32 dimensions. The primitive-polynomial degrees,
coefficients, and initial direction numbers are recorded in the source table;
the Gray-code state transition and point mapping are implemented locally.

The numerical parameters and recurrence follow the published Joe–Kuo Sobol
construction. The primary references are:

- Stephen Joe and Frances Y. Kuo, “Remark on Algorithm 659: Implementing
  Sobol's Quasirandom Sequence Generator,” ACM Transactions on Mathematical
  Software 29(1), 49–57 (2003), DOI
  [10.1145/641876.641879](https://doi.org/10.1145/641876.641879).
- Stephen Joe and Frances Y. Kuo, “Constructing Sobol Sequences with Better
  Two-Dimensional Projections,” SIAM Journal on Scientific Computing 30(5),
  2635–2654 (2008), DOI
  [10.1137/070709359](https://doi.org/10.1137/070709359).
- The authors' [Sobol sequence resource page](https://web.maths.unsw.edu.au/~fkuo/sobol/),
  which documents the `d, s, a, m` parameter format used by the implementation.

The repository does not vendor reference implementation source code. It uses
the published numerical parameterization and provides independent MoonBit
implementation, boundary tests, deterministic replay tests, and a 32-dimensional
benchmark workload.
