[Numpy-discussion] random seed replicate 2d randn with 1d loop

Robert Kern robert.kern at gmail.com
Mon May 23 15:02:35 EDT 2011

On Mon, May 23, 2011 at 13:33,  <josef.pktd at 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?

No general guarantee for all of the scipy distributions, no. I suspect
that all of the RandomState methods do work this way, though.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco

More information about the NumPy-Discussion mailing list