[Numpy-discussion] Bug or feature?

Sune Rastad Bahn bahn at atomistix.com
Thu Nov 10 01:53:15 CST 2005


Dear devs,

Thanks a lot for a very nice and extremely useful python module.
I recommend all my colleagues to try you package whenever they ask for a 
matlab like environment. This week one of these friends came by me with an 
oddity relating to the RandomArray module.

try the following on your linux command prompt:

while true;
do python -c "from RandomArray import *;seed();print randint(100000)";
done

and check the output. I get a steadily but slowly decreasing series of 
numbers. e.g:

4013
4013
4012
4012
4012
4012
4012
4012
4012
4012
4010
4010
4010

According to the documentation seed() should initiatilize from the system 
clock. If one checks the seed (using get_seed) it turns out to be the case 
indeed, but that it is only very slowly changing (once a second), and only on 
the second seed. e.g

python -c "from RandomArray import *;seed();print get_seed()"

(113161, 3079)
(113161, 3079)
(113161, 3080)
(113161, 3080)
(113161, 3080)
(113161, 3080)

My best guess is that this is the cause for the behavior seen above.

This could be filed as a feature, but I believe it is not the behavior people 
would expect. At least the documentation should emphasize 

that two runs started within a short time ( upto 1s) will give the exact same 
result (experts on pseudo random numbers will know this, but the length of 
the time 1sec is surprisingly long).

that the first random number is slowly varying (strongly correlated) with time 
(this is more surprising). One fix is to take one randomnumber and throw 
away, since the second number is not correlated with time (except from noted 
above).

Best,
Sune




-- 
Software Application Manager
Sune Rastad Bahn
Phone:  +45 35 320 638
Mobile: +45 23 455 997
Email: bahn at atomistix.com




More information about the Numpy-discussion mailing list