On 6/22/06, Robert Kern <[EMAIL PROTECTED]> wrote: > Keith Goodman wrote: > > How do I seed rand and randn? > > If you can, please use the .rand() and .randn() methods on a RandomState > object > which you can initialize with whatever seed you like. > > In [1]: import numpy as np > rs > In [2]: rs = np.random.RandomState([12345678, 90123456, 78901234]) > > In [3]: rs.rand(5) > Out[3]: array([ 0.40355172, 0.27449337, 0.56989746, 0.34767024, > 0.47185004])
Using the same seed sometimes gives different results: from numpy import random def rtest(): rs = random.RandomState([11,21,699,1]) a = rs.rand(100,1) b = rs.randn(100,1) return sum(a + b) >> mytest.rtest() array([ 41.11776129]) >> mytest.rtest() array([ 40.16631018]) >> numpy.__version__ '0.9.7.2416' I ran the test about 20 times before I got the 40.166 result. Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion