Rotate-Multiply (Romu) Generators¶
-
class randomgen.romu.Romu(seed=
None
, variant='quad'
)¶ Mark A. Overton’s quad and trio rotate-multiply-based generators
- Parameters:¶
- seed=
None
¶ A seed to initialize the BitGenerator. If None, then fresh, unpredictable entropy will be pulled from the OS. If an
int
orarray_like[ints]
is passed, then it will be passed to SeedSequence to derive the initial BitGenerator state. One may also pass in a SeedSequence instance.- variant=
'quad'
¶ The variant to use. The Quad variant is somewhat slower but has a larger state.
- seed=
Notes
Romu
is a rotate-multiply based generator either either a 256-bit state (default, “quad”) or a 192-bit state (“trio”) ([1], [2]).Romu
has a large capacity and has a tiny chance of overlap, especially when using the default “quad” variant. It is extremely fast.Romu
provides a capsule containing function pointers that produce doubles, and unsigned 32 and 64- bit integers. These are not directly consumable in Python and must be consumed by aGenerator
or similar object that supports low-level access.State and Seeding
The
Romu
state vector consists of 3 (“trio”) or 4 unsigned 64-bit values. The input seed is processed by SeedSequence to generate all values, then theRomu
algorithm is iterated a small number of times to mix.Compatibility Guarantee
Romu
makes a guarantee that a fixed seed will always produce the same random integer stream.Examples
Romu
supports parallel application using distinct seed values.>>> from randomgen import SeedSequence, Romu >>> NUM_STREAMS = 8192 >>> seed_seq = SeedSequence(489048146361948) >>> bit_gens = [Romu(child) for child in seed_seq.spawn(NUM_STREAMS)] >>> [bg.random_raw() for bg in bit_gens[:3]] [9130649916277841551, 2156737186088199787, 12803009197309261862]
References
Seeding and State¶
|
Seed the generator |
Get or set the PRNG state |
Extending¶
CFFI interface |
|
ctypes interface |
Testing¶
|
Return randoms as generated by the underlying BitGenerator |