- #1

- 5

- 0

**Fortran's Random numbers!!**

Hi everyone!

I have a doubt about random numbers on Fortran: how does the computer choose random numbers? Why don't they change each time I run the programme? Are they really random then?

Thanks!

You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

- Fortran
- Thread starter michela02
- Start date

- #1

- 5

- 0

Hi everyone!

I have a doubt about random numbers on Fortran: how does the computer choose random numbers? Why don't they change each time I run the programme? Are they really random then?

Thanks!

- #2

- 1,065

- 54

randomness in itself is a complicated matter...I think you need to read up on it.

I don't know much about randomness, all I can tell is that I can imagine different algorithms are probably designed to generate a series of random numbers, where the randomness has to do with the fact that the numbers do not follow a certain pattern or sequence or something...now, because it is an algorithm that generates the numbers, there is a repeatability in the process, the process is started with what is called a seed...whenever you start with the same seed, the sequence of numbers is going to be the same...again, that does not mean that it is not a random sequence...got it? the randomnes is in the non-pattern of the sequence.

- #3

Borek

Mentor

- 28,816

- 3,323

They are pseudorandom, most likely prepared using linear congruential generator. You should be able to modify the seed (which will make the sequence different each time).

- #4

- 1,868

- 0

If you need a very large amount of random numbers, then it may be beneficial to use the Mersenne twister: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/FORTRAN/fortran.html

Share: