You mislead RandomState with seed . Your first line creates an object that can then be used as your random source. For example, we do
>>> rnd = np.random.RandomState(3) >>> rnd <mtrand.RandomState object at 0xb17e18cc>
and then
>>> rnd.choice(range(20), (5,)) array([10, 3, 8, 0, 19]) >>> rnd.choice(range(20), (5,)) array([10, 11, 9, 10, 6]) >>> rnd = np.random.RandomState(3) >>> rnd.choice(range(20), (5,)) array([10, 3, 8, 0, 19]) >>> rnd.choice(range(20), (5,)) array([10, 11, 9, 10, 6])
[I donโt understand why your idx1 and idx1S agree - but you have not actually published stand-alone decrypted text, so I suspect a user error.]
If you want to influence the global state, use seed :
>>> np.random.seed(3) >>> np.random.choice(range(20),(5,)) array([10, 3, 8, 0, 19]) >>> np.random.choice(range(20),(5,)) array([10, 11, 9, 10, 6]) >>> np.random.seed(3) >>> np.random.choice(range(20),(5,)) array([10, 3, 8, 0, 19]) >>> np.random.choice(range(20),(5,)) array([10, 11, 9, 10, 6])
Using a specific RandomState object may seem less convenient at first, but it makes it a lot easier when you want to set up various entropy streams that you can set up.