question about random number generation

Carlos Ribeiro carribeiro at gmail.com
Fri Sep 10 19:21:19 EDT 2004


On Fri, 10 Sep 2004 11:37:38 -0600, lu.fan at seagate.com
<lu.fan at seagate.com> wrote:
> I'm a newbie in Python. I have a question about the random number generation in Python vs. Java. 
> We have a system developed in Python. Now I'm writing tests in Java (actually a Java wrapper) to test it. I need to duplicate a random number generation process in my test which means that given the same seed I expect the same result in Java as in Python. As far as I know, Python uses the Mersenne Twister RNG --- correct me if I am wrong. Do Python and Java use the same RNG? 

Although you're a newbie in Python, for what you have written I assume
that you understand the issues regarding RNG. As the other poster
mentioned, the only way to guarantee the generation of the same
sequence is by using a RNG routine of your own. That's more difficult
than it may seem at first because RNG algorithms have lots of pitfalls
and your random numbers may end up not being as random as you think.
If you really know what you're doing (and I assume you do), feel free
to ignore my advice :-)


-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com



More information about the Python-list mailing list