- Random number generation
A random number generator (often abbreviated as RNG) is a computational or physical device designed to generate a sequence of
numbers or symbols that lack any pattern, i.e. appear random. Computer-based systems for random number generation are widely used, but often fall short of this goal, though they may meet some statistical tests for randomness intended to ensure that they do not have any easily discernible patterns. Methods for generating random results have existed since ancient times, including dice, coin flipping, the shufflingof playing cards, the use of yarrowstalks in the I Ching, and many other techniques.
applications of randomnesshave led to many different methods for generating random data. These methods may vary as to how unpredictable or statistically random they are, and how quickly they can generate random numbers.
Before the advent of computational random number generators, generating large amount of sufficiently random numbers (important in statistics) required a lot of work. Results would sometimes be collected and distributed as
random number tables.
The earliest methods for generating random numbers —
dice, coin flipping, roulettewheels — are still used today, mainly in games and gambling as they tend to be too slow for applications in statistics and cryptography.
Some physical phenomena, such as thermal noise in
Zener diodes appear to be truly random and can be used as the basis for hardware random number generators. However, many mechanical phenomena feature asymmetries and systematic biases that make their outcomes not truly random. The many successful attempts to exploit such phenomena by gamblers, especially in rouletteand blackjackare testimony to these effects. [http://www.cs.sunysb.edu/~skiena/jaialai/excerpts/node5.html]
There are several imaginative sources of random numbers online. A common technique is to run a
hash functionagainst a frame of a video stream from an unpredictable source. This technique was used by Lavarandwho used images of a number of lava lamps. Lithium Technologiesuses a camera pointed at the sky on a windy and cloudy day. Random.org has a more obvious approach of listening to atmospheric noise. Details about how they turn their input into random numbers can be found on their respective sites. Completely randomized designfalls within the category of true random number generation. The generation of true random numbers outside the computer environment is based on the theory of entropy. Sources of entropy include nuclear decay and atmospheric conditions. [http://www.fourmilab.ch/hotbits/ HotBits] uses radioactive decay, while [http://www.Random.org Random.org] uses radio noise to generate randomness.
Pseudo-random number generators (PRNGs) are algorithms that can automatically create long runs (for example, millions of numbers long) with good random properties but eventually the sequence repeats exactly (or the memory usage grows without bound). One of the most common PRNG is the linear congruential generator, which uses the recurrence
to generate numbers. The maximum number of numbers the formula can produce is the
modulus, "m". To avoid certain non-random properties of a single linear congruential generator, several such random number generators with slightly different values of the multiplier coeffient "a" are typically used in parallel, with a "master" random number generator that selects from among the several different generators.
A simple pen-and-paper method for generating random numbers is the so-called
middle square methodsuggested by John Von Neumann. While simple to implement, its output is of poor quality.
Most computer programming languages include functions or library routines that purport to be random number generators. They are often designed to provide a random byte or word, or a
floating pointnumber uniformly distributed between 0 and 1.
Such library functions often have poor statistical properties and some will repeat patterns after only tens of thousands of trials. They are often initialized using a computer's
real time clockas the seed. These functions may provide enough randomness for certain tasks (for example video games) but are unsuitable where high-quality randomness is required, such as in cryptographic applications, statistics or numerical analysis. Much higher quality random number sources are available on most operating systems; for example /dev/randomon various BSD flavors, Linux, Mac OS X, IRIX, and Solaris, or CryptGenRandomfor Microsoft Windows.
Practical applications and uses of random numbers
Random number generators have applications in
gambling, statistical sampling, computer simulation, cryptography, and other areas where a random number is useful in producing an unpredictable result.
Note that, in general, where unpredictability is paramount--such as in security applications-- hardware generators are generally preferred, where feasible, over pseudo-random algorithms.
Random number generators are very useful in developing
Monte Carlo methodsimulations as debuggingis facilitated by the ability to run the same sequence of random numbers again by starting from the same " random seed". They are also used in cryptographyso long as the "seed" is secret. Sender and receiver can generate the same set of numbers automatically to use as keys.
The generation of
pseudo-random numbers is an important and common task in computer programming. While cryptography and certain numerical algorithms require a very high degree of "apparent" randomness, many other operations only need a modest amount of unpredictability. Some simple examples might be presenting a user with a "Random Quote of the Day", or determining which way a computer-controlled adversary might move in a computer game. Weaker forms of "randomness" are also closely associated with hash algorithms and in creating amortized searching and sorting algorithms.
Some applications which appear at first sight to be suitable for randomization are in fact not quite so simple. For instance, a system that 'randomly' selects music tracks for a background music system must only "appear" to be random; a true random system would have no restriction on the same item appearing two or three times in succession.Fact|date=June 2008
Activities and demonstrations
SOCRresource pages contain a number of [http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_RNG hands-on interactive activities and demonstrations] of random number generation using Java applets.
"True" random numbers vs. pseudorandom numbers
There are two principal methods used to generate random numbers. One measures some physical phenomenon that is expected to be random and then compensates for possible biases in the measurement process. The other uses computational
algorithms that produce long sequences of apparently random results, which are in fact completely determined by a shorter initial value, known as a seed or key. The latter type are often called pseudorandom number generators.
A "random number generator" based solely on deterministic computation "cannot" be regarded as a "true" random number generator, since its output is inherently predictable.
John von Neumannfamously said "Anyone who uses arithmetic methods to produce random numbers is in a state of sin." How to distinguish a "true" random number from the output of a pseudo-random number generator is a very difficult problem. However, carefully chosen pseudo-random number generators can be used instead of true random numbers in many applications. Rigorous statistical analysis of the output is often needed to have confidence in the algorithm.
Generating random numbers from physical processes
There is general agreement that, if there are such things as "true" random numbers, they are most likely to be found by looking at physical processes which are, as far as is known, unpredictable.
A physical random number generator can be based on an essentially random atomic or subatomic physical phenomenon whose unpredictability can be traced to the laws of
quantum mechanics. An example of this are the Atari 8-bit computers, which used electronic noisefrom an analog circuit to generate true random numbers. [http://www.atarimagazines.com/v7n11/randomatari.html] Other examples include radioactive decay, thermal noise, shot noiseand clock drift. Even lava lamps have been used by the Lavarandgenerator.
To provide a degree of randomness intermediate between specialized hardware on the one hand and algorithmic generation on the other, some security related computer software requires the user to input a lengthy string of mouse movements, or keyboard input.
Post-processing and statistical checks
Even given a source of plausible random numbers (perhaps from a quantum mechanically based hardware generator), obtaining numbers which are completely unbiased takes care. In addition, behavior of these generators often changes with temperature, power supply voltage, the age of the device, or other outside interference. And a software bug in a pseudo-random number routine, or a hardware bug in the hardware it runs on, may be similarly difficult to detect.
Generated random numbers are sometimes subjected to statistical tests before use to ensure that the underlying source is still working, and then post-processed to improve their statistical properties.
Random numbers uniformly distributed between 0 and 1 can be used to generate random numbers of any desired distribution by passing them through the inverse
cumulative distribution function(CDF) of the desired distribution. Inverse CDFs are also called quantile functions. To generate a pair of statistically independent standard normally distributed random numbers ("x", "y"), one may first generate the polar coordinates("r", "θ"), where "r"~χ22 and "θ"~UNIFORM(0,2π) (see Box-Muller transform).
Some 0 to 1 RNGs include 0 but exclude 1, while others include or exclude both.
The outputs of multiple independent RNGs can be combined (for example, using a bit-wise
XORoperation) to provide a combined RNG at least as good as the best RNG used. This is referred to as software whitening.
Computational and hardware random number generators are sometimes combined to reflect the benefits of both kinds. Computational random number generators can typically generate pseudo-random numbers much faster than physical generators can generate true randomness.
Low-discrepancy sequences as an alternative
Some computations making use of a random number generator can be summarized as the computation of a total or average value, such as the computation of integrals by the
Monte Carlo method. For such problems, it may be possible to find a more accurate solution by the use of so-called low-discrepancy sequences, also called quasirandomnumbers. Such sequences have a definite pattern that fills in gaps evenly, qualitatively speaking; a truly random sequence may, and usually does, leave larger gaps.
Generation from a probability distribution
There are a couple of methods to generate a random number based on a
probability density function. These methods involve transforming a uniform random number in some way. Because of this, these methods work equally well in generating both pseudo-random and true random numbers. One method, called the inversion method, involves integrating up to an area greater than or equal to the random number (which should be generated between 0 and 1 for proper distributions). A second method, called the acceptance-rejection method, involves choosing an x and y value and testing whether the function of x is greater than the y value. If it is, the x value is accepted. Otherwise, the x value is rejected and the algorithm tries again. [http://www.mathworks.com/access/helpdesk/help/toolbox/stats/index.html]
Hardware random number generator
List of random number generators
Random number generator attack
Random password generator
"Random numbers available over the internet and from parties not specifically known to and trusted by the user should not be used cryptographically."
* [http://www.numberator.com Numberator.com] (Generates millions of numbers and codes sequentially or randomly online in seconds. Free version available.)
* [http://gotentropy.artofinfosec.com Got Entropy ? ] (Cryptographic quality seeds/random numbers generated from RF noise)
* [http://Yuzoz.com/ Yuzoz.com ] (random numbers generated from live space events)
* [http://blogs.msdn.com/michael_howard/archive/2005/01/14/353379.aspx Cryptographically Secure Random number on Windows without using CryptoAPI] from MSDN
* [http://www.random.org Random.org - generate random bitmaps, flip virtual coins etc.] (random numbers generated from
atmospheric noisefrom a radio)
* [http://www.fourmilab.ch/hotbits/ HotBits: Genuine Random Numbers] (random numbers generated from
* [http://www.lavarnd.org/demo/index.html LavaRnd demonstration] (random numbers generated from a webcam CCD chip)
* [http://www.randomnumbers.info/ RandomNumbers.info] (random numbers generated by exploiting elementary quantum optics process)
* [http://www.kenotracker.com/keno/Random.asp KenoRND()] (random numbers generated from results of live keno at real casinos)
* [http://www.true-random.com/ www.true-random.com] (random numbers generated from digital noise and based on the central limit theorem)
* [http://www.westphal-electronic.com/ True (physical) random number generators (e.g. with USB interface)]
* http://www.idquantique.com/products/quantis.htm - True random number generators based on quantum physics
* http://random.mat.sbg.ac.at - uniform random number generators
* [http://www.embedded.com/showArticle.jhtml?articleID=20900500 Generating random numbers] Generating random numbers in
* [http://www.saccenti.com/randomnumber/randomnumber.htm Free Random Number Generator] Open-source code for creating random numbers using Visual Basic
* [http://rqube.seifseit.de RQube] Free software for generating random sequences for experimental purpose in
behavioural sciencesand social sciences.
* [http://www.westphal-electronic.com/zgloss_e.htm Glossary of words concerning true random number generation]
Wikimedia Foundation. 2010.