zbtong zbtong - 1 year ago 317
Python Question

The difference between np.random.seed(int) and np.random.seed(array_like)?

In python's numpy library, the

method can accept two different type of parameter:
, what's the difference between them? Such as:
np.random.seed([2013, 1, 4])

Answer Source

The state of the underlying Mersenne Twister PRNG is very large, 624 32-bit integers, to be exact. If given an integer seed, the initialization routine will run a smaller PRNG to expand that single 32-bit integer out to the full 624-element state. This does mean that you can't access the vast majority of the possible states.

Similarly, if given a sequence of integers as the seed, then a different smaller PRNG will use that to expand out to 624 elements, but one that can use the whole array that you pass it. This lets you access the whole space of initial states, if such a thing matters to you. This algorithm is shared between the standard library's random module and numpy.random.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download