rng = numpy.random.RandomState(23355)
arrayA = rng.uniform(0,1,(2,3))
这里看以看到,有一个23355这个数字,其实,它是伪随机数产生器的种子,也就是“the starting point for a sequence of pseudorandom number”
1 # 仍以上面的seed为例,但执行多次
2 # 利用循环,执行4次
3 import numpy
4 for i in [1,2,3,4]:
5 rng = numpy.random.RandomState(23455)
6 arrayA = rng.uniform(0,1,(2,3))
7 print arrayA
1 import numpy
2 for i in [1,2,3,4]:
3 rng = numpy.random.RandomState(23455+i)
4 arrayA = rng.uniform(0,1,(2,3))
5 print (‘i = %s‘ % (i))
6 print (arrayA)
7