473,327 Members | 2,103 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

random seed

By default, randomm module uses the timestamp to generate the seed
value. Is it possible to know what that seed value is?

import random
random.random()
# How do I print the current value of the seed?
Thanks
Vivek

Aug 16 '05 #1
4 4583
vi*******@gmail.com wrote:
By default, randomm module uses the timestamp to generate the seed
value. Is it possible to know what that seed value is?


From a (very) quick glance at the doc [1], I'm not sure you can get it.

But if you want to reuse it later (for a deterministic behaviour), you
can get and set the internal state of the generator (using getstate and
setstate).

[1] http://docs.python.org/lib/module-random.html
Aug 16 '05 #2
Thanks. I guess I will use the system time and pass it as seed
explicitly. My goal is to replicate the random numbers that I generate
to ensure repeatabilty in the regression test suite that I am trying
to write.

Aug 16 '05 #3
vi*******@gmail.com wrote:
Thanks. I guess I will use the system time and pass it as seed
explicitly. My goal is to replicate the random numbers that I generate
to ensure repeatabilty in the regression test suite that I am trying
to write.


In that case you should just pick a single seed yourself instead of
getting it from system time.

random.seed(1234567890)

is traditional and works just fine.

Other favorites:

3141592653589793
2718281828459045

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Aug 16 '05 #4
Robert Kern wrote:
random.seed(1234567890)

is traditional and works just fine.

Other favorites:

3141592653589793
2718281828459045


Nothing beats 42!
(That was just an exclamation mark in the end, no factorial intended.)

371 is another nice number, since it's its own reverse in hex.

If you liked 3141592653589793, you might also like 113355. :)
Aug 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Sonoman | last post by:
Hi all: I am trying to write a simple program that simulates asking several persons their birth day and it counts how many persons are asked until two have the same birth day. The problem that I...
16
by: Jason | last post by:
Hi, I need a way to use random numbers in c++. In my c++ project, when using the mingw compiler I used a mersenne twister that is publicly available and this did its job well. Now I have...
3
by: Joe | last post by:
Hi, I have been working on some code that requires a high use of random numbers within. Mostly I either have to either: 1) flip a coin i.e. 0 or 1, or 2) generate a double between 0 and 1. I...
4
by: Jack | last post by:
I have two files: sort_comparison.c++ my_sort.h sort_comparison.c++ calls this code in my_sort.h: void my_sort::fillArray(int arr,int n) { // const int random_number_range=1000000;
4
by: Jonathan Burd | last post by:
Greetings everyone, Here is a random string generator I wrote for an application and I'm wondering about the thread-safety of this function. I was told using static and global variables cause...
10
by: Marshall Belew | last post by:
I'm trying to synchronize a network app that uses random numbers generated by System.Random. Rather than pass every randomly generated number, I just pass the seed. I'm seeing a result that leads...
10
by: Curt_C [MVP] | last post by:
If I use it in my page it's fine but when I put it in a Class file for calling it returns the same # for each call. Any ideas why? I'm sure it's something I'll slap myself for but the only samples...
3
by: George Durzi | last post by:
How can I choose a random integer between to given integers? For example, I'd like to pick a random integer between 1 and 3. E.g. 1, 2, or 3 If I do Dim oRandom As New Random(1)...
12
by: Jim Michaels | last post by:
I need to generate 2 random numbers in rapid sequence from either PHP or mysql. I have not been able to do either. I get the same number back several times from PHP's mt_rand() and from mysql's...
8
by: Daniel | last post by:
Hey guys Using Random(), how random is it, is it possible to be predicted? I have a requirement for a very good random number generator. I was doing something such as: Random randomSeed = new...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.