Skip to main content

Module pcg

Module pcg 

Source
Expand description

PCG32 / PCG64 generators (feature pcg). PCG (Permuted Congruential Generator) family - O’Neill, 2014.

Two variants exported:

  • Pcg32 - PCG-XSH-RR-64/32. 16-byte state, 32-bit output. The smallest-state member of the family; faster per u32 than Xoshiro256++ on most CPUs.
  • Pcg64 - PCG-XSL-RR-128/64. 32-byte state, 64-bit output. Same state size as Xoshiro256++ with native 64-bit output.

Both are statistically excellent (pass TestU01 BigCrush) but are not CSPRNGs - same caveat as Xoshiro and MT.

Reference: O’Neill, M. E. (2014), PCG: A Family of Simple Fast Space-Efficient Statistically Good Algorithms for Random Number Generation. https://www.pcg-random.org/.

Structs§

Pcg32
PCG-XSH-RR-64/32 generator. 16-byte state (one u64 LCG state plus a 64-bit stream-selecting increment); 32-bit output per call via XOR-shift-high followed by random rotation.
Pcg64
PCG-XSL-RR-128/64 generator. 32-byte state (one u128 LCG state plus a 128-bit increment); 64-bit output per call via XOR-shift-low followed by random rotation.