A random-seed is used to initialize a pseudo-random number generator in many programming languages.
Questions tagged [random-seed]
937 questions
12
votes
3 answers
Reproducible results using Keras with TensorFlow backend
I am using Keras to build a deep learning LSTM model, using TensorFlow backend. Each time I run the model, the result is different. Is there a way to fix the seed to create reproducible results? Thank you!

Edamame
- 23,718
- 73
- 186
- 320
11
votes
6 answers
Is seeding data with fixtures dangerous in Ruby on Rails
I have fixtures with initial data that needs to reside in my database (countries, regions, carriers, etc.). I have a task rake db:seed that will seed a database.
namespace :db do
desc "Load seed fixtures (from db/fixtures) into the current…

Tony
- 18,776
- 31
- 129
- 193
11
votes
4 answers
Butterfly pattern appears in random walk using srand(), why?
About 3 years ago I coded a 2D random walk togheter with a coleague in C++, first it seemed to work properly as we obtained a diferent pattern each time. But whenever we decided to increase the number of steps above some threshold an apparent…

Isidre Mas Magre
- 149
- 7
11
votes
1 answer
comprehensive way to check for functions that use the random number generator in an R script?
is there a smart way to identify all functions that use .Random.seed (the random number generator state within R) at any point in an R script?
use case: we have a dataset that changes constantly, both the records [rows] and the information…

Anthony Damico
- 5,779
- 7
- 46
- 77
11
votes
2 answers
Random seed Math.random in Java
In my code I use random numbers in different classes. How to define random seed? Can I define this seed for all the classes in the main code?
double rnd = Math.random();

Klausos Klausos
- 15,308
- 51
- 135
- 217
10
votes
5 answers
Is there a way to generate a seed out of a sequence of numbers?
For example if java produces the pseudorandom sequence: 9 3 2 5 6
by using 23 as a seed, how can I do the inverse? i.e. getting 23 out of the sequence 9 3 2 5 6.
Or how do I assign a seed for a certain sequence?
It is easy to do if there is a…

Frank Smith
- 1,717
- 4
- 18
- 32
10
votes
5 answers
Generating random values from uniform distribution with setting a seed in T-SQL
I would like to generate a random value from the uniform distribution with mean=0 and a standard devation=1 for every row of a given data table in T-SQL. Additionally, I would like to set a seed in order to ensure reproducibility of analysis. Here…

kaksat
- 709
- 1
- 7
- 18
10
votes
3 answers
Difference between Python 2 and 3 for shuffle with a given seed
I am writing a program compatible with both Python 2.7 and 3.5. Some parts of it rely on stochastic process. My unit tests use an arbitrary seed, which leads to the same results across executions and languages... except for the code using…

Aristide
- 3,606
- 2
- 30
- 50
10
votes
3 answers
Difference between math.random() and math.randomseed() in Lua
I am working on game using Corona SDK with Lua as Programming Language . While getting random number from table , I am confused to use which one of following ?
math.random()
math.randomseed()
Will any one elaborate the exact difference between them…

Salman Nazir
- 2,759
- 2
- 28
- 42
10
votes
2 answers
How can I store the state of the pseudo-random generator in Perl?
Is there a way to store the current state of the built in pseudo-random number generator in Perl so that when my program is run again, it can pick up the sequence from where it left off rather than starting with a new sequence?
Right now, I am…

Sinan Ünür
- 116,958
- 15
- 196
- 339
10
votes
1 answer
How to seed randn function opencv
I want to seed randn function but I'm not able to do it.
srand(time(NULL));
Mat mymat = Mat::zeroes(1024,1024,CV_32F);
randn(mymat,0,1);
Should it not give me random mat, named mymat, whose mean = 0, and variance = 1? However, it gives the same…

smttsp
- 4,011
- 3
- 33
- 62
10
votes
1 answer
Scala Random what does seed do when creating random object
I'm fairly new to scala so this might be a stupid question. I know when you do nextInt(seed) it uses the seed but when you create the object, what is the seed for? For example in this line of code:
val rnd = new scala.util.Random(1000)
this seems…

user2870571
- 101
- 1
- 1
- 3
9
votes
2 answers
What features of xgboost are affected by seed (random_state)?
The Python API doesn't give much more information other than that the seed= parameter is passed to numpy.random.seed:
seed (int) – Seed used to generate the folds (passed to numpy.random.seed).
But what features of xgboost use…

gosuto
- 5,422
- 6
- 36
- 57
9
votes
1 answer
Why is numpy random seed not remaining fixed but RandomState is when run in parallel?
I am running a monte-carlo simulation in parallel using joblib. I noticed however although my seeds were fixed my results kept changing. However, when I ran the process in series it remained constant as I expect.
Below I implement a small example,…

RK1
- 2,384
- 1
- 19
- 36
9
votes
3 answers
C++ random yields different numbers for same Mersenne Twister seed when using float precision
I need to run reproducible Monte Carlo runs. That means I use a known seed that I store with my results, and use that seed if I need to run the same problem instance using the same random numbers. This is common practice.
While investigating the…

Escualo
- 40,844
- 23
- 87
- 135