Reputation: 23
When I do the following in Python:
>>> import numpy
>>> numpy.random.RandomState()
it returns RandomState(MT19937) at 0x2BABD069FBA0
. I understand the first part of the output, but I fail to understand the meaning of the hexadecimal part. It doesn't seem to be the random seed as well. I tried to check online but couldn't find any information on this. Please may I ask if anyone understands the meaning of the hexadecimal number? Many thanks!
Upvotes: 2
Views: 222
Reputation: 1430
As others have mentioned, that's the address of the object.
I assume you are interested in a form of representation of the state that can be saved and possibly restored at a later time.
If that's the case you can use get_state()
in the following way:
In [1]: import numpy
In [2]: rs = numpy.random.RandomState()
In [3]: state = rs.get_state()
In [4]: rs.rand()
Out[4]: 0.432259232330229
In [5]: rs.rand()
Out[5]: 0.8136168709684055
In [6]: rs.set_state(state)
In [7]: rs.rand()
Out[7]: 0.432259232330229
In [8]: rs.rand()
Out[8]: 0.8136168709684055
In [9]: state
Out[9]:
('MT19937',
array([2147483648, 3210667685, 2075287668, 1343092412, 968114203,
2132083310, 3622729752, 1799367345, 3280163148, 1700822427,
[...]
1081150080, 3649194061, 1333345922, 800258004, 1698645582,
3374395214, 2706341428, 849808433, 570983609], dtype=uint32),
623,
0,
0.0)
The last line shows "the random seed".
Upvotes: 1
Reputation: 115
I think it is the memory address pointing to where the object was instanced
>>> x = np.random.RandomState()
>>> x
RandomState(MT19937) at 0x2D5545AAE40
>>> print(hex(id(x)))
0x2d5545aae40
Upvotes: 2