View Single Post
Old 10-24-2007, 05:28 PM   #12
Apocalyptic Poster
smashingpumpkin's Avatar
Posts: 1,016

This is all sort of confusing. I figured I can help some folks with the random number issue. Check out the external links really usefull stuff.

Random number generator
From Wikipedia, the free encyclopedia
• Have questions? Find out how to ask questions and get answers. • It has been suggested that this article or section be merged into Random number generation. (Discuss)

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 shuffling of playing cards, the use of yarrow stalks in the I Ching, and many other techniques.Contents [hide]
1 "True" random numbers vs. pseudo-random numbers
2 Random numbers in computing
3 Generating random numbers from physical processes
4 Post-processing and statistical checks
5 Other considerations
6 Uses of random numbers
7 Low-discrepancy sequences as an alternative
8 Generation from a probability distribution
9 See also
10 External links

"True" random numbers vs. pseudo-random numbers
Main article: pseudorandom number generator

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 Neumann famously 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.

Random numbers in computing

Most computer programming languages ******* 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 point number 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 clock as 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/random on various BSD flavors, Linux, Mac OS X, IRIX, and Solaris, or CryptGenRandom for Microsoft Windows.

Generating random numbers from physical processes
Main article: hardware random number generator

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 we know, unpredictable.

A physical random number generator can be based on an essentially random atomic or subatomic physical phenomenon whose randomness can be traced to the laws of quantum mechanics. An example of this is the Atari gaming console, which used noise from an analog circuit to generate true random numbers. [1] Other examples ******* radioactive decay, thermal noise, shot noise and clock drift. Even Lava Lamps have been used.

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.
See also: Statistical randomness

Other considerations

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 of the desired distribution. Inverse CDFs are also called quantile functions. To generate a pair of 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 ******* 0 but exclude 1, while others ******* or exclude both.

The outputs of multiple independent RNGs can be combined (for example, using a bit-wise XOR operation) to provide a combined RNG at least as good as the best RNG used. More details about uncorrelated near random bit streams.

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.

Uses of random numbers
Main article: Applications of randomness

Random number generators have applications in gambling, statistical sampling, computer simulation, cryptography, etc.

Note that, in general, where unpredictability is paramount--such as in security applications-- hardware generators are generally preferred, where feasible, over pseudo-random algorithms.

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 quasirandom numbers. 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 distribution function. These methods involve transforming a normal 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. [2]

See also
Hardware random number generator
List of random number generators
Random number generator attack
Random password generator

External links

Random numbers available over the internet and from parties not specifically known to and trusted by the user should not be used cryptographically.
Cryptographically Secure Random number on Windows without using CryptoAPI from MSDN - generate random bitmaps, flip virtual coins etc. (random numbers generated from atmospheric noise from a radio)
Simple Random Number Generator Software (Uses three different algorithms]
HotBits: Genuine Random Numbers (random numbers generated from radioactive decays)
LavaRnd demonstration (random numbers generated from a webcam CCD chip) (random numbers generated by exploiting elementary quantum optics process)
Free Open-Source Generator (Random number generator with open-source code for Windows)
KenoRND() (random numbers generated from results of live keno at real casinos) (random numbers generated from digital noise and based on the central limit theorem)
True (physical) random number generators (e.g. with USB interface) - True random number generators based on quantum physics - uniform random number generators
Generating random numbers Generating random numbers in Embedded Systems
RQube Free software for generating random sequences for experimental purpose in behavioural sciences and social sciences.
Glossary of words concerning true random number generation

smashingpumpkin is offline