Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are my random numbers always the same?

I'm using the random_number subroutine from Fortran, but in different runs of program the number which is being produced doesn't change. What should I include in my code so every time I compile and run the program the numbers change?

like image 741
mojijoon Avatar asked May 26 '14 18:05

mojijoon


People also ask

Can you generate the same random numbers everytime?

random seed() example to generate the same random number every time. If you want to generate the same number every time, you need to pass the same seed value before calling any other random module function. Let's see how to set seed in Python pseudo-random number generator.

What is the most random number ever?

We are told that MIPS chip designer Mark Johnson, who claims it is the World's most common random number, is responsible for scribbling this number onto the mask. A number of visitors have responded to us about the concept of 37 being the most random number.

Can random number be same?

In that sense the answer here is 'no'. With that in mind, any proper RNG ought to be producing sequences of identical numbers of arbitrarily long length with positive (albeit shrinking) probability.


1 Answers

The random number generator produces pseudo-random numbers. To get different numbers each run, you need to initialise the random seed at the start of your program. This picks a different starting position in the pseudo-random stream.

like image 122
ire_and_curses Avatar answered Sep 24 '22 02:09

ire_and_curses