Uniform random number generator (RNG)

In summary, the conversation discusses the use of a Random Number Generator (RNG) subroutine in a Fortran program and the search for a faster and longer period RNG. The speaker has previously used ran1 from "Numerical Recipes in Fortran, second edition, Page 271" but found it to be slow. They have searched for faster subroutines but have not found any that meet their requirements. George Marsaglia, a developer of PRNGs, is suggested as a potential resource. The speaker is also reminded that it is difficult to have both fast and good performance in an RNG.
  • #1
Carter2x
4
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
  • #3
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.
 
  • #4
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.
 
  • #5


I understand the importance of using a reliable and efficient random number generator (RNG) in your program. While ran1 from Numerical Recipes in Fortran may be a commonly used subroutine, it is understandable that you are looking for a faster option.

There are several factors to consider when choosing an RNG, including speed, period length, and randomness. It is important to balance these factors to ensure that your results are both accurate and efficient.

One way to find a suitable RNG is to consult established scientific literature and research. There are many studies and comparisons of different RNG algorithms that have been published in scientific journals. These studies often include performance evaluations, such as speed and period length, which can help you make an informed decision.

Another option is to look for RNG libraries specifically designed for scientific computing. These libraries are often optimized for speed and have been extensively tested and validated by the scientific community. Some popular examples include the GNU Scientific Library and the Random123 library.

In addition, some hardware manufacturers also offer fast and reliable RNGs, such as Intel's Random Number Generator Instruction (RDRAND) and AMD's Secure Random Number Generator (SRNG). These options may require additional setup and configuration, but they can provide high-quality random numbers with long periods.

Overall, I recommend doing thorough research and considering all factors before choosing an RNG for your program. It is also important to properly test and validate your results to ensure the accuracy and reliability of your simulations or calculations.
 

Related to Uniform random number generator (RNG)

What is a uniform random number generator (RNG)?

A uniform random number generator (RNG) is a mathematical algorithm or device that produces a sequence of numbers that have no discernible pattern and are evenly distributed within a specified range. This means that each number in the sequence has an equal probability of being generated.

Why is a uniform RNG important in scientific research?

A uniform RNG is important in scientific research because it allows for the generation of truly random and unbiased samples, which are necessary for accurate statistical analysis. It is also used in simulations and modeling to mimic real-world randomness and variability.

How does a uniform RNG work?

A uniform RNG typically uses a seed value, which is a starting point for the algorithm. The algorithm then calculates a series of random numbers based on the seed value, using mathematical operations such as multiplication and addition. The resulting numbers are then scaled and shifted to fit within the desired range.

What are the limitations of a uniform RNG?

A uniform RNG can only generate numbers within a specified range and some algorithms may have a limited period, meaning that the sequence of numbers may eventually repeat. It also cannot produce truly random numbers, as it is based on a deterministic algorithm. Additionally, the quality of the RNG depends on the quality of the seed value and the algorithm used.

How can I test the quality of a uniform RNG?

There are several statistical tests that can be used to evaluate the quality of a uniform RNG, such as the chi-square test and the Kolmogorov-Smirnov test. These tests assess whether the generated numbers are truly random and follow a uniform distribution. Another method is to plot a histogram of the generated numbers and visually inspect for any patterns or biases.

Similar threads

  • Programming and Computer Science
Replies
1
Views
805
  • Programming and Computer Science
Replies
22
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Programming and Computer Science
Replies
9
Views
2K
  • Programming and Computer Science
Replies
19
Views
2K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
7
Views
4K
Replies
1
Views
4K
  • Programming and Computer Science
Replies
15
Views
2K
Back
Top