numpyrandomnumpy-random

How to inspect BitGenerator state in a numpy.random.Generator object?


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?


Solution

  • 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,