Fortran How Does Fortran Generate Random Numbers?

  • Thread starter Thread starter michela02
  • Start date Start date
  • Tags Tags
    Numbers Random
Click For Summary
Fortran generates random numbers using algorithms that produce pseudorandom sequences, meaning they appear random but are generated through a deterministic process. The key to this process is the "seed," which initializes the algorithm; using the same seed will yield the same sequence of numbers. This repeatability does not negate the randomness of the sequence, as the numbers do not follow a predictable pattern. Fortran commonly employs a linear congruential generator for this purpose. To achieve different sequences in each run, users can modify the seed. For applications requiring a larger quantity of random numbers, the Mersenne Twister algorithm is recommended for its improved randomness properties.
michela02
Messages
5
Reaction score
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!
 
Technology news on Phys.org


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.
 


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).
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 21 ·
Replies
21
Views
7K
  • · Replies 26 ·
Replies
26
Views
9K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 6 ·
Replies
6
Views
3K
Replies
16
Views
3K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K