我运行了以下代码:
我得到的输出如下所示:
np.random.RandomState(3)
idx1 = np.random.choice(range(20),(5,))
idx2 = np.random.choice(range(20),(5,))
np.random.RandomState(3)
idx1S = np.random.choice(range(20),(5,))
idx2S = np.random.choice(range(20),(5,))
我得到的输出如下所示:
idx1: array([ 2, 19, 19, 9, 4])
idx1S: array([ 2, 19, 19, 9, 4])
idx2: array([ 9, 2, 7, 10, 6])
idx2S: array([ 5, 16, 9, 11, 15])
idx1和idx1S匹配,但idx2和idx2S不匹配。我期望一旦我种下随机数生成器并重复相同的命令序列 - 它应该产生相同的随机数序列。这不是真的吗?还是我遗漏了什么其他的东西?