If I have a numpy.random.Generator
, what's the best way to inspect the BitGenerator
used internally? And does the BitGenerator
have any state that impacts what numbers are generated?
CodePudding user response:
With a generator in my test work space
In [101]: rng.__getstate__()
Out[101]:
{'bit_generator': 'PCG64',
'state': {'state': 146432235854318609275567707501468323380,
'inc': 280910788252749725750054959837409577313},
'has_uint32': 0,
'uinteger': 454544037}
After creating some random numbers the state
changes
'state': {'state': 189704257871557326744081098317112680436,
CodePudding user response:
I know it's lame to answer my own question but i did just figure out that _bit_generator
is an attribute of Generator
objects:
>>> import numpy as np
>>> rng = np.random.default_rng(seed=0)
>>> print(rng._bit_generator)
<numpy.random._pcg64.PCG64 at 0x7f97c7bb7b90>
>>> print(rng._bit_generator.state)
{'bit_generator': 'PCG64',
'state': {'state': 35399562948360463058890781895381311971,
'inc': 87136372517582989555478159403783844777},
'has_uint32': 0,
'uinteger': 0}