None
, idx=None
, original=True
)¶
Container for the Tychee pseudo-random number generator.
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 is None
, then data is read from /dev/urandom
(or the Windows analog) if available.
None
¶
The index to use when seeding from a SeedSequence. If None, the default, the index is selected at random.
True
¶
If True, use the original Tyche implementation. If False, use the OpenRand implementation. Default is True.
Lock instance that is shared so that the same bit git 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.
The SeedSequence instance used to initialize the generator if mode is “sequence” or is seed is a SeedSequence.
{None, SeedSequence}
Notes
Tyche
[1] is a pseudo-random number generator based on the Tyche PRNG. It is a 32-bit PRNG that uses a set 4 32-bit unsigned integers as state, and operates using only addition, subtraction, rotation and xor.
State and Seeding
The EFIIX64
state vector consists of 4 32-bit unsigned integers. The seed
value is translated into a 64-bit unsigned integer. If idx
is not None, it is translated into a 32-bit unsigned integer.
Compatibility Guarantee
Tyche
makes a guarantee that a fixed seed will always produce the same random integer stream.
Examples
>>> from numpy.random import Generator
>>> from randomgen import Tyche
>>> rg = Generator(Tyche(1234))
>>> rg.standard_normal()
0.123 # random
Parallel Features
Tyche
can be used in parallel when combined with a SeedSequence
using spawn
.
>>> from randomgen import SeedSequence
>>> entropy = 8509285875904376097169743623867
>>> ss = SeedSequence(entropy)
>>> bit_gens = [Tyche(child) for child in ss.spawn(1024)]
Alternatively, the same seed
value can be used with different idx
values.
>>> from randomgen import SeedSequence
>>> bit_gens = [Tyche(SeedSequence(entropy), idx=i) for i in range(1024)]
References
seed
([seed])
Seed the generator
Get or set the PRNG state
Extending¶ Testing¶random_raw
([size, output])
Return randoms as generated by the underlying BitGenerator
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4