Uniform random number generator (RNG)

Click For Summary
The discussion centers on the search for a faster and longer-period Random Number Generator (RNG) for a Fortran program. The user is currently using the ran1 RNG from "Numerical Recipes in Fortran," but finds it slow and inadequate due to its short period. They have explored other RNGs, including those in C/C++, but found them to be slower. Suggestions include considering RNGs developed by George Marsaglia, which offer various options for generating integers and floating-point values. However, there is a debate on the balance between speed and quality, with some participants noting that while ran1 is fast, it has a short period and may not be the best choice for high-quality random number generation.
Carter2x
Messages
3
Reaction score
0
I am writing a program in Fortran language, in which i use a Random Number Generator (RNG) subroutine.
Until now i used ran1 from " Numerical Recipes in fortran ,second edition, Page 271 ", but i think it is quite slow.
While searching on the internet for a faster RNG i found a few Fortran subroutines
(many were in other languages C/C++ ...), but they were slower than the one i had.
Do you know were can i find a fast and quite longperiod (>= 10^12) RNG ?
 
Technology news on Phys.org
Carter2x said:
I am writing a program in Fortran language, in which i use a Random Number Generator (RNG) subroutine.
Until now i used ran1 from " Numerical Recipes in fortran ,second edition, Page 271 ", but i think it is quite slow.
While searching on the internet for a faster RNG i found a few Fortran subroutines
(many were in other languages C/C++ ...), but they were slower than the one i had.
Do you know were can i find a fast and quite longperiod (>= 10^12) RNG ?

Have you tried using the one that's part of the language?

George Marsaglia developed a number of PRNGs.
Some produce integers directly, others produce floating-point values directly.
 
Carter2x said:
Until now i used ran1 from " Numerical Recipes in fortran ,second edition, Page 271 ", but i think it is quite slow.
ran1 is fast, but it is lousy (it has way too short a period). What makes you think it is slow?

You can have fast or you can have good. Asking for both at once is a bit much.
 
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
22
Views
5K
  • · Replies 9 ·
Replies
9
Views
2K
Replies
7
Views
4K
Replies
19
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
9K
  • · Replies 6 ·
Replies
6
Views
7K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K