[ python-Bugs-1023453 ] script which sets random.seed still returns random value

SourceForge.net noreply at sourceforge.net
Tue Sep 7 10:47:30 CEST 2004


Bugs item #1023453, was opened at 2004-09-07 00:40
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1023453&group_id=5470

Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Faheem Mitha (fmitha)
Assigned to: Nobody/Anonymous (nobody)
Summary: script which sets random.seed still returns random value

Initial Comment:
Hi,

The following text is in the README in the attached
tarball. Note also that I'd be happy to try to narrow
down the bug further, if indeed there is one. I just
wanted to confirm first that there indeed was a bug.

This is with python 2.3 and numarray 1.0 on Debian sarge.
ii  python-numarray            1.0-2                  
   An array processing package modelled after
Python-Numeric
ii  python                     2.3.4-1                
   An interactive high-level object-oriented language
(default version)

(By the way, I'd really, really prefer to submit
reports via email, like the Debian bug tracking
system). It is also not very convenient to follow up to
replies.
                                                      
                      Faheem

*************************************************************
Run the included script (requires python 2.3)

python bug.py

Even though the seed is set before gendata is called,
every time the script is run, a different matrix is
printed. It seems to me that this should not happen. My
interest in this case is ensuring
reproducibility for debugging purposes.

I am not an expert on random numbers, so I may be
missing some subtle point. If so, I'm appreciate it if
my error was explained to me.

Thanks.                                               
Faheem Mitha.


----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2004-09-07 03:47

Message:
Logged In: YES 
user_id=80475

There are two independent random number generators in your
code.  

One is in the random module and you're accessing it with
random.seed() and random.gammavariate().  The seed operation
will correctly make gammavariate() create a reproducable
sequence.

The second is in numarray.random_array.multinomial.  This
generator is provided by numarray and needs its own seed
operation.  Seed it, and your program ought to work fine. 
See the numarray docs for details on how to seed random_array.

For the future, please do not attach tar.gz files.  They are
a nuisance to review.  More importantly, you should pair
down the report to the simplest possible code that
reproduces the error.  Otherwise, a reviewer has to read all
of your code to figure out what you're doing.

Good luck and happy computing.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1023453&group_id=5470


More information about the Python-bugs-list mailing list