Crates.io | lcg69069 |
lib.rs | lcg69069 |
version | 0.9.2 |
source | src |
created_at | 2024-08-03 22:46:48.026771 |
updated_at | 2024-08-10 09:33:14.291121 |
description | LCG69069 / MTH$RANDOM Pseudorandom linear congruential generator |
homepage | https://gitlab.com/hsn10/lcg69069 |
repository | https://gitlab.com/hsn10/lcg69069.git |
max_upload_size | |
id | 1324571 |
size | 17,630 |
LCG69069 is Pseudo random Linear congruential generator (LCG) that uses multiplier parameter 69069.
This parameter is proposed by George Marsaglia as a "candidate for the best of all multipliers":
I nominate 69069 = 3 * 7 * 11 * 13 * 23. This palindromically convoluted multiplier is easy to remember and has a nearly cubic lattice for moduli 2^32, 2^35, 2^36.
LCG69069 uses coeficients: multiplier a = 69096, increment c = 1 and modulus m = 2^32.
It can be implemented very quickly on 32-bit hardware in just 2 operations: wrapping multiplication by a and wrapping addition of c. By using 32-bit registers value is automaticaly truncated to correct range; modulus operation is not needed.
Generated values are full 32 bit unsigned integers range with period 2^32.
LCG69069 is used in the VAX VMS Math library as function MTH$RANDOM and is often known as VAX RANDOM. It is also part of a combined Generator called SUPER-DUPER.
Multiplicative congruential pseudo-random number generator. Its special case of LCG with coeficient c zero. On 32-bit hardware this generator is implemented by single wrapping multiplication operation. This variant is suitable for generating random noise on GPU, see spectral test bellow.
Generated values are full 32 bit unsigned integers range with period 2^30. This is limitation of MCG generators with 2^N modulus, they have /4 period of LCG. LCG generators always perform better than corresponding MCG variants.
https://en.wikipedia.org/wiki/Linear_congruential_generator
modulus | 2d | 3d | 4d | 5d | 6d | 7d | 8d |
---|---|---|---|---|---|---|---|
2^32 | 0.4625 | 0.3131 | 0.4572 | 0.5529 | 0.3767 | 0.4967 | 0.6852 |
2^35 | 0.6935 | 0.8595 | 0.6347 | 0.7000 | 0.2664 | 0.3690 | 0.5284 |
2^36 | 0.4904 | 0.6822 | 0.7760 | 0.6094 | 0.4746 | 0.3342 | 0.4845 |
The LCG version yields better
spectral test results.
This is free and unencumbered software released into the public domain.