A Good Fortran Random Number Generator

5

The FORTRAN GNA (rand ()) seems to be bad, this is because it is proved to be worse than very simple random number generators. For example, in my simulations the GNA below

SUBROUTINE GNA(iiseed)
USE Variaveis
parameter (ia=843314861,ib=453816693,m=1073741824, r231=1./2147483648.)
INTEGER :: iiseed

iiseed = ib + ia*iiseed
if (iiseed.lt.0) iiseed = (iiseed+m) + m
RndNum = iiseed*r231

END SUBROUTINE GNA

proved to be better than the FORTRAN rand (), and this GNA is quite simple. Would anyone know to tell me a good random number generator (GNA) in FORTRAN. Something that combines computational time efficiency and randomness of generated numbers.

    
asked by anonymous 22.10.2015 / 01:30

2 answers

2

There are several algorithms for generating numbers pseudo random and the choice of the ideal algorithm depends a lot on the purpose for which the numbers will be generated.

The most widely used algorithm today is the Mersenne Twister - Wikipedia which, according to the article, presents among other advantages, a long period (% with%), so the "randomness" of the numbers is better.

If you prefer a faster algorithm, you can use the Xorshift - Wikipedia (examples of implementation are in C language ), or some of its variations.

Another option to use is to get a list of random numbers in a service, such as Random.ORG > and use these numbers in your program by reading them from a file.

There are other services like Random.org (and other algorithms as well), which you can check out at Wikipedia - Random Number Generator List .

Here are some sites that already provide PRNG source code for FORTRAN:

Alan Miller's Fortran Software

Multiple stream Mersenne Twister PRNG

Mersenne Twister Home Page Mersenne Twister Home Page

NOOA

Source Codes in Fortran90 and F90_RANDOM

Random number generation

    
27.01.2016 / 04:24
1

Hello, how are you? So I use Marsaglia. It has a very large period and very little execution time. They've done a lot of testing with him on correlations and he's within the acceptable range. To use, in your program or routine that will use it, simply put it in the USE random_utilities header and, before starting, call the CALL subroutine initrandom (i, it). If you need to use the same seed for comparison, you can call rmarin (ij, kl) where 0

28.09.2017 / 06:30