A random-seed is used to initialize a pseudo-random number generator in many programming languages.
Questions tagged [random-seed]
692 questions
434
votes
16 answers
Seeding the random number generator in Javascript
Is it possible to seed the random number generator (Math.random) in JavaScript?
weepy
- 4,801
- 3
- 18
- 10
204
votes
9 answers
Is java.util.Random really that random? How can I generate 52! (factorial) possible sequences?
I've been using Random (java.util.Random) to shuffle a deck of 52 cards. There are 52! (8.0658175e+67) possibilities. Yet, I've found out that the seed for java.util.Random is a long, which is much smaller at 2^64 (1.8446744e+19).
From here, I'm…
Sergei Emelianov
- 4,666
- 6
- 23
- 43
186
votes
12 answers
random.seed(): What does it do?
I am a bit confused on what random.seed() does in Python. For example, why does the below trials do what they do (consistently)?
>>> import random
>>> random.seed(9001)
>>> random.randint(1, 10)
1
>>> random.randint(1, 10)
3
>>> random.randint(1,…
Ahaan S. Rungta
- 1,925
- 2
- 10
- 13
109
votes
4 answers
Differences between numpy.random and random.random in Python
I have a big script in Python. I inspired myself in other people's code so I ended up using the numpy.random module for some things (for example for creating an array of random numbers taken from a binomial distribution) and in other places I use…
Laura
- 1,622
- 2
- 14
- 21
77
votes
4 answers
How can I retrieve the current seed of NumPy's random number generator?
The following imports NumPy and sets the seed.
import numpy as np
np.random.seed(42)
However, I'm not interested in setting the seed but more in reading it. random.get_state() does not seem to contain the seed. The documentation doesn't show an…
Mast
- 1,542
- 4
- 25
- 42
51
votes
1 answer
Should I use `random.seed` or `numpy.random.seed` to control random number generation in `scikit-learn`?
I'm using scikit-learn and numpy and I want to set the global seed so that my work is reproducible.
Should I use numpy.random.seed or random.seed?
From the link in the comments, I understand that they are different, and that the numpy version is not…
shadowtalker
- 8,614
- 2
- 34
- 70
34
votes
2 answers
Inconsistent results for f(g(x)) together or split up
During a recent investigation into setting random seeds within functions, I came across an odd situation. Consider functions f and g, each of which sets the random seed and then performs a simple randomized operation:
g <- function(size) {…
josliber
- 41,865
- 12
- 88
- 126
32
votes
10 answers
Is there an alternative to using time to seed a random number generation?
I'm trying to run several instances of a piece of code (2000 instances or so) concurrently in a computing cluster. The way it works is that I submit the jobs and the cluster will run them as nodes open up every so often, with several jobs per node.…
CHP
- 825
- 5
- 13
- 25
31
votes
6 answers
Best way to seed mt19937_64 for Monte Carlo simulations
I'm working on a program that runs Monte Carlo simulation; specifically, I'm using a Metropolis algorithm. The program needs to generate possibly billions of "random" numbers. I know that the Mersenne twister is very popular for Monte Carlo…
Mathhead200
- 331
- 3
- 6
29
votes
7 answers
How do I get the seed from a Random in Java?
I am creating a deep clone for some object. The object contains a Random.
Is it good practice to retrieve the seed from the Random? If so, how? There isn't a Random.getSeed().
Marnix
- 6,004
- 4
- 35
- 67
28
votes
2 answers
Is set.seed consistent over different versions of R (and Ubuntu)?
I am currently running R version 3.1.0 (on Ubuntu 12.04 LTS) and as both my R version and my operating system is getting rather old, I plan on updating both. However, I have a lot of simulations that rely on set.seed() and I would like them to still…
Phil
- 555
- 1
- 4
- 14
27
votes
1 answer
What is the scope of a random seed in Python?
If I use the Python function random.seed(my_seed) in one class in my module, will this seed remain for all the other classes instantiated in this module?
Lyrositor
- 373
- 4
- 7
22
votes
7 answers
Reproducible results in Tensorflow with tf.set_random_seed
I am trying to generate N sets of independent random numbers. I have a simple code that shows the problem for 3 sets of 10 random numbers. I notice that even though I use the tf.set_random_seed to set the seed, the results of different runs do not…
Mehdi Rezaie
- 256
- 1
- 2
- 7
22
votes
4 answers
setting seed for excel random number
In excel below formula will generate random number from a normal distribution with mean 10 and variance 1. Is there a way to set a fix seed so that i get a fix set of random numbers all the time? I am using Excel 2010
=NORMINV(RAND(),10,1)
user2543622
- 4,682
- 20
- 62
- 117
20
votes
4 answers
Generating uniform random numbers in Lua
I am working on programming a Markov chain in Lua, and one element of this requires me to uniformly generate random numbers. Here is a simplified example to illustrate my question:
example = function(x)
local r = math.random(1,10)
print(r)
…
Starfish_Prime
- 217
- 1
- 2
- 5