ab.random¶
Random generators and state.
-
class
aboleth.random.
SeedGenerator
¶ Bases:
object
Make new random seeds deterministically from a base random seed.
-
next
()¶ Generate a random int using this object’s base state.
Returns: result – an integer that can be used to seed other random states deterministically. Return type: int
-
set_hyperseed
(hs)¶ Set the random seed state in this object.
Parameters: hs (None, int, array_like) – seed the random state of this object, see numpy.random.RandomState for valid inputs.
-
-
aboleth.random.
endless_permutations
(N)¶ Generate an endless sequence of permutations of the set [0, ..., N).
If we call this N times, we will sweep through the entire set without replacement, on the (N+1)th call a new permutation will be created, etc.
Parameters: N (int) – the length of the set Yields: int – yeilds a random int from the set [0, ..., N) Examples
>>> perm = endless_permutations(5) >>> type(perm) <class 'generator'> >>> p = next(perm) >>> p < 5 True >>> p2 = next(perm) >>> p2 != p True
-
aboleth.random.
set_hyperseed
(hs)¶ Set the global hyperseed from which to generate all other seeds.
Parameters: hs (None, int, array_like) – seed the random state of the global hyperseed, see numpy.random.RandomState for valid inputs.