Xorshift1024*φ¶
-
class randomgen.xorshift1024.Xorshift1024(seed=
None)¶ Container for the xorshift1024*φ pseudo-random number generator.
- Parameters:¶
- seed=
None¶ Entropy initializing the pseudo-random number generator. Can be an integer in [0, 2**64), array of integers in [0, 2**64), a SeedSequence instance or
None(the default). If seed isNone, a new SeedSequence is created using entropy from the operating system.
- seed=
- lock¶
Lock instance that is shared so that the same bit generator can be used in multiple Generators without corrupting the state. Code that generates values from a bit generator should hold the bit generator’s lock.
- Type:¶
- seed_seq¶
The SeedSequence instance used to seed the generator. If seed is not a SeedSequence, one is created from it.
- Type:¶
{None, SeedSequence}
Notes
xorshift1024*φ is a 64-bit implementation of Saito and Matsumoto’s XSadd generator [1] (see also [2], [3], [4]). xorshift1024*φ has a period of \(2^{1024} - 1\) and supports jumping the sequence in increments of \(2^{512}\), which allows multiple non-overlapping sequences to be generated.
Xorshift1024provides 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 aGeneratoror similar object that supports low-level access.See
Xoroshiro128for a faster bit generator that has a smaller period.State and Seeding
The
Xorshift1024state vector consists of a 16-element array of 64-bit unsigned integers.Xorshift1024is seeded using either a single 64-bit unsigned integer or a vector of 64-bit unsigned integers. In either case, the seed is used as an input to a SeedSequence, and the output of the SeedSequence is used as the initial state. Using a single 64-bit value for the seed can only initialize a small range of the possible initial state values.Parallel Features
Xorshift1024can be used in parallel applications by calling the methodjumpedwhich advances the state as-if \(2^{512}\) random numbers have been generated. This allows the original sequence to be split so that distinct segments can be used in each worker process. All generators should be initialized with the same seed to ensure that the segments come from the same sequence.>>> from numpy.random import Generator >>> from randomgen import Xorshift1024 # Advance each Xorshift1024 instance by i jumps >>> rg = [Generator(Xorshift1024(1234).jumped(i)) for i in range(10)]Compatibility Guarantee
Xorshift1024makes a guarantee that a fixed seed will always produce the same random integer stream.Examples
>>> from numpy.random import Generator >>> from randomgen import Xorshift1024 >>> rg = Generator(Xorshift1024(1234)) >>> rg.standard_normal() 0.123 # randomReferences
Seeding and State¶
|
Seed the generator |
Get or set the PRNG state |
Parallel generation¶
|
Returns a new bit generator with the state jumped |
Extending¶
CFFI interface |
|
ctypes interface |
Testing¶
|
Return randoms as generated by the underlying BitGenerator |