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?
Asked
Active
Viewed 107 times
0

Peter O.
- 32,158
- 14
- 82
- 96

william_grisaitis
- 5,170
- 3
- 33
- 40
2 Answers
0
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,

hpaulj
- 221,503
- 14
- 230
- 353
-
i also added an answer but i'm accepting yours as a thank you – william_grisaitis Nov 18 '21 at 23:57
0
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}

william_grisaitis
- 5,170
- 3
- 33
- 40