Numeric RandomArray seed problem

A

ajikoe

Hello,

I tried calling RandomArray.seed()
by calling RandomArray.get_seed() I get the seed number (x,y).
My problem is that x is always 113611 any advice?

Thanks
pujo
 
S

Sean Richards

Hello,

I tried calling RandomArray.seed()
by calling RandomArray.get_seed() I get the seed number (x,y).
My problem is that x is always 113611 any advice?


In [1]: from RandomArray import *

In [2]: seed?
Type: function
Base Class: <type 'function'>
String Form: <function seed at 0x407a1534>
Namespace: Interactive
File: /usr/lib/python2.3/site-packages/Numeric/RandomArray.py
Definition: seed(x=0, y=0)
Docstring:
seed(x, y), set the seed using the integers x, y;
Set a random one from clock if y == 0


In [3]: seed(123,456)

In [4]: get_seed()
Out[4]: (123, 456)

Cheers, Sean
 
R

Robert Kern

Hello,

I tried calling RandomArray.seed()
by calling RandomArray.get_seed() I get the seed number (x,y).
My problem is that x is always 113611 any advice?

Well, RandomArray.seed() gets its seed from the computer's time.

def seed(x=0,y=0):
"""seed(x, y), set the seed using the integers x, y;
Set a random one from clock if y == 0
"""
if type (x) != IntType or type (y) != IntType :
raise ArgumentError, "seed requires integer arguments."
if y == 0:
import time
t = time.time()
ndigits = int(math.log10(t))
base = 10**(ndigits/2)
x = int(t/base)
y = 1 + int(t%base)
ranlib.set_seeds(x,y)

As you can see, x won't change much if the difference in t is small.

Note, that in scipy_core, the random number facilities have been
completely rewritten. We now use the Mersenne Twister algorithm, which
uses 2496 bytes of state instead of 8 like RandomArray. On UNIX-type
systems with a /dev/urandom and also Windows, the default seed (all
2496 bytes of state) is drawn from the OS's "cryptographic PRNG" where
available.
 
A

ajikoe

Hello Tim,

If I created a matrix with a randomArray the first elements in the
matrix (row index 0 and col index 0) will change very small. Actually
this leads me to check the seed, and found that seed don't change
anything since I check in an hour duration. I found that it changes
very slow though.

pujo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top