[Numpy-discussion] random seed replicate 2d randn with 1d loop
josef.pktd at gmail.com
josef.pktd at gmail.com
Mon May 23 14:33:09 EDT 2011
I have a function in two versions, one vectorized, one with loop
the vectorized function gets all randn variables in one big array
rvs = distr.rvs(args, **{'size':(nobs, nrep)})
the looping version has:
for irep in xrange(nrep):
rvs = distr.rvs(args, **{'size':nobs})
the rest should be identical (except for vectorization
Is there a guarantee that the 2d arrays are filled up in a specific
order so that the loop and vectorized version produce the same result,
given the same seed?
In my example it doesn't work, ( bootstrap p-values for
Anderson-Darling A^2 with estimated loc and scale)
>>> np.random.seed(8765679)
>>> [bootstrap2(c/ (1 + 4./nobs - 25./nobs**2), NewNorm(), args=(0,1), nobs=nobs, nrep=10000) for c in [0.576, 0.656, 0.787, 0.918, 1.092]]
[0.14449999999999999, 0.0901, 0.042200000000000001, 0.0212, 0.0076]
>>> np.random.seed(8765679)
>>> [bootstrap(NewNorm(), args=(0,1), nobs=nobs, nrep=10000, value=c/ (1 + 4./nobs - 25./nobs**2)) for c in [0.576, 0.656, 0.787, 0.918, 1.092]]
[0.14710000000000001, 0.092899999999999996, 0.044499999999999998,
0.022800000000000001, 0.0080999999999999996]
>>> np.array([15.0, 10.0, 5.0, 2.5, 1.0])/100. #Stephens
array([ 0.15 , 0.1 , 0.05 , 0.025, 0.01 ])
Josef
More information about the NumPy-Discussion
mailing list