471,091 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,091 software developers and data experts.

Numeric RandomArray seed problem

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

Jan 1 '06 #1
4 1853

"aj****@gmail.com" <aj****@gmail.com> writes:
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

--
"Hver sin smak", sa vintapperen, han drakk mens de andre sloss."
Jan 2 '06 #2
"aj****@gmail.com" <aj****@gmail.com> wrote:

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?


What did you expect?
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jan 3 '06 #3
aj****@gmail.com wrote:
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.

Jan 3 '06 #4
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

Jan 5 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by beliavsky | last post: by
2 posts views Thread by Johannes Nix |Johannes.Nix | last post: by
19 posts views Thread by Peter Ammon | last post: by
2 posts views Thread by William Ortenberg | last post: by
4 posts views Thread by vivek7006 | last post: by
10 posts views Thread by Leon | last post: by
reply views Thread by Johannes Nix | last post: by
7 posts views Thread by Sheldon | last post: by
4 posts views Thread by kalar | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.