[Numpy-discussion] random number generation in python compared to gsl

Sebastian Haase haase@msg.ucsf....
Wed Nov 5 05:28:05 CST 2008


On Wed, Nov 5, 2008 at 11:30 AM, Giovanni Samaey
<giovanni.samaey@cs.kuleuven.be> wrote:
> Hi all,
> I have a question concerning the Mersenne Twister random number generation
> in numpy:  when I seed it with 0, I get a different sequence of numbers in
> numpy, compared to GSL.
> In numpy:
> r = numpy.Random.RandomState(seed=0)
> r.uniform(size=5)  ---->  array([ 0.5488135 ,  0.71518937,  0.60276338,
>  0.54488318,  0.4236548 ])
> whereas in GSL the first numbers are
> 0.99974 0.16291 0.2826 0.94720  0.23166
> Matlab gives the same result as numpy...
> I have translated some python code to c, and would like to debug it --
> therefore, I would like to have exactly the same set of random numbers...
>  How can I provoke this ?
> Best.
> Giovanni

Hi,
how about other seed values ?  I thought seed=0, is (often) used to
mean a "random", i.e. current time or alike, seed value ... !?

-Sebastian Haase


More information about the Numpy-discussion mailing list