On Mon, May 23, 2011 at 11:33 AM, <josef.p...@gmail.com> wrote: > 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?
Are you pulling the numbers from rows or columns of the 2d array? Columns seem to work: >> rs = np.random.RandomState([1,2,3]) >> rs.randn(3,3) array([[ 0.89858245, 0.25528877, 0.95172625], [-0.05663392, 0.54721555, 0.11512385], [ 0.82495129, 0.17252144, 0.74570118]]) which gives the same as >> rs = np.random.RandomState([1,2,3]) >> rs.randn(3) array([ 0.89858245, 0.25528877, 0.95172625]) >> rs.randn(3) array([-0.05663392, 0.54721555, 0.11512385]) >> rs.randn(3) array([ 0.82495129, 0.17252144, 0.74570118]) I get similar results with np.random.seed _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion