It is a computational or physical device designed to generate a sequence of numbers or symbols that lack any pattern, i.e. appear random. Hardware-based systems for random number generation are widely used, but often fall short of this goal, though they may meet some of the statistical tests for randomness intended to ensure that they do not have any easily discernible patterns.
RNG have applications in gambling, statistical sampling, computer simulation, cryptography, completely randomized design, and other areas where a random number is useful in producing an unpredictable result.
Random number generators are very useful in developing Monte Carlo method simulations as debugging is 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 cryptography so 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.
1. Physical Methods. 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. The earliest methods for generating random numbers — dice, coin flipping, roulette wheels — are still used today, mainly in games and gambling as they tend to be too slow for applications in statistics and cryptography. Generating true random numbers outside the computer environment is based on the theory of entropy. 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. Sources of entropy include radioactive decay, thermal noise, shot noise, clock drift, and atmospheric conditions.
Various imaginative ways of collecting this entropic information have been devised. Atari 8-bit computers used electronic noise from an analog circuit to generate true random numbers. One common technique is to run a hash function against a frame of a video stream from an unpredictable source. Lavarand used this technique with images of a number of lava lamps. Lithium Technologies uses a camera pointed at the sky on a windy and cloudy day. HotBits measures radioactive decay with GM tubes, while Random.org uses variations in the amplitude of atmospheric noise recorded with a normal radio.
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 roulette and blackjack are testimony to these effects. Another common entropy source is the behavior of human users of the system, if such users exist. While humans are not considered good randomness generators upon request, they generate random behavior quite well in the context of playing mixed strategy games. Some security-related computer software requires the user to input a lengthy string of mouse movements or keyboard input to add a certain degree of randomness to computational pseudo-random number generation.
2.Computational Methods.Pseudo-random number generators (PRNGs) are algorithms that can automatically create long runs with good random properties but eventually the sequence repeats (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.
or
Xn = (aXn-1 + b) mod m
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 coefficient 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 method suggested 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 point number uniformly distributed between 0 and 1.