An Random generator is a tool or algorithm that produces unpredictable and non-deterministic results. These generators are essential in many areas, from cryptography to computer simulation.
- Unpredictable results: Random generators deliver results that cannot be predicted.
- Use in cryptography: They are crucial for secure communication.
- Computer simulations: Frequently used in the modelling and analysis of complex systems.
Random number generator
How does a random number generator work? ?
Random generators work either with physical processes or mathematical algorithms. The most important types are true random number generators (TRNGs) and pseudo-random number generators (PRNGs).
Where do we play blackjack online?
We have had the best experiences at Black Jack in the Playamo Live Casino made. In my opinion, that's where it's at, BEST SELECTION at tables with live dealers and you can train very well for the real casino! Compared to other online casinos, the winnings at Playamo are really paid out and that's why I would definitely recommend Playamo Online Casino!
The Playamo Casino has many live tables for blackjack and a Fast payment of Win.
Various applications of randomness have led to the development of different methods of generating random data. Some of these have existed since ancient times, including well-known examples such as throwing dice, tossing coins, shuffling playing cards, using yarrow stalks (for divination) in the I Ching, and countless other techniques. Due to the mechanical nature of these techniques, generating large quantities of sufficiently random numbers (important in statistics) required a lot of labour and time. Therefore, the results were sometimes collected and distributed as tables of random numbers.
There are several computational methods for generating pseudorandom numbers. All of them fail to achieve the goal of true randomness, although they do, with varying degrees of success, fulfil some of the statistical Tests for randomness, which are designed to measure how unpredictable their results are (i.e. to what extent their patterns are recognisable). This makes them generally unusable for applications such as cryptography. However, there are also carefully designed cryptographically secure pseudorandom number generators (CSPRNGS) with special features designed specifically for the Insert were developed in cryptography.
Applications of random generators
- Games and entertainment:
- Random generators are used in games to create unpredictable elements such as dice rolls, card draws or level generation.
- Cryptography:
- In information security, random number generators are crucial for the generation of keys, salts and nonces, which are required for encryption and authentication.
- Statistics and samples:
- When creating samples for surveys and studies, random generators help to draw representative and unbiased samples.
- Simulation models:
- In science and technology, random number generators are used to perform Monte Carlo simulations that use random variables to model and analyse complex systems.
- Lotteries and competitions:
- They ensure the fair and random selection of winners in lotteries, sweepstakes and other competitions.
- Optimisation algorithms:
- Random methods such as genetic algorithms and simulated annealing use random generators to efficiently search solution spaces and find optimal solutions.
- Artificial intelligence and machine learning Learning:
- Random generators are used to mix data sets and randomly select training and test data to validate and train the models.
Random number generators have applications in Gamblingin statistical sampling, computer simulation, cryptography, fully randomised design and other areas where the generation of an unpredictable result is desirable. In general, in applications where unpredictability is the key feature, such as security applications, hardware generators are favoured where possible.
Pseudorandom number generators are very useful in the development of Monte Carlo simulation methods, as debugging is facilitated by being able to repeat the same sequence of random numbers when starting with the same random seed. They are also used in cryptography - as long as the seed remains secret. The sender and receiver can automatically generate the same set of numbers to use as a key.
The generation of pseudorandom 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 require only a modest degree of unpredictability. Some simple examples might be presenting a user with a "random quote of the day" or determining which direction a computer-controlled opponent in a computer game might move. Weaker forms of randomness are used in hashing algorithms and in the creation of amortised search and sorting algorithms.
Some applications that seem suitable for randomisation at first glance are not so simple in reality. For example, a system that "randomises" music tracks for a background music system only needs to appear randomly and may even have ways of controlling the music selection: a truly randomised system would have no restriction on the same track appearing two or three times in a row.
Real random numbers vs. pseudo-random numbers ?
The difference between real and pseudo-random numbers lies in the predictability and the source of the randomness.
- Real random numbers: Unpredictable, based on physical processes.
- Pseudo-random numbers: Generated by algorithms, predictable if the seed is known.
There are two main methods for generating random numbers. The first method measures a physical phenomenon that is considered random and then compensates for possible distortions in the measurement process. Examples of sources include the measurement of atmospheric noise, thermal noise and other external electromagnetic and quantum mechanical phenomena. For example, cosmic background radiation or radioactive decay measured over short periods of time are sources of natural entropy (as a measure of the unpredictability or surprise of the number generation process).
The rate at which entropy can be extracted from natural sources depends on the underlying physical phenomena being measured. Therefore, sources of naturally occurring "true" entropy are said to be blocking - they are rate-limited until enough entropy is collected to meet demand. On some Unix-like systems, including most Linux distributions, the pseudo device file /dev/random blocks until sufficient entropy is collected from the environment. Because of this blocking behaviour, large bulk data reads from /dev/random, such as filling a hard drive with random bits, can often be slow on systems that use this type of entropy source.
The second method uses computational algorithms that can generate long sequences of seemingly random results that are in fact completely determined by a shorter initial value, known as the seed value or key. This allows the entire seemingly random sequence to be reproduced if the seed value is known. This type of random number generator is often referred to as a pseudorandom number generator. This type of generator is usually non-blocking, so it is not rate-limited by an external event, allowing for large bulk data reads.
Some systems use a hybrid approach that collects randomness from natural sources when available and relies on cryptographically secure pseudorandom number generators (CSPRNGs) that are periodically reseeded when the desired read rate exceeds the ability of the natural collection approach to meet demand. This approach avoids the rate-limited blocking behaviour of random number generators based on slower and purely environment-based methods.
While a pseudorandom number generator based solely on deterministic logic can never be considered a "true" random source in the purest sense of the word, they are generally sufficient in practice, even for demanding security-critical applications. Carefully designed and implemented pseudorandom number generators can be certified for security-critical cryptographic purposes, as is the case with the Yarrow and Fortuna algorithms. The former is the basis of the /dev/random entropy source on FreeBSD, AIX, macOS, NetBSD and others. OpenBSD uses a pseudorandom number algorithm known as arc4random.
Generation methods
Physical methods
The earliest methods of generating random numbers, such as dice rolls, coin tosses and roulette wheels, are still used today, mainly in games and gambling, as they are too slow for most applications in statistics and cryptography.
A physical random number generator can be based on an essentially random atomic or subatomic physical phenomenon whose unpredictability can be attributed to the laws of quantum mechanics. Sources of entropy include radioactive decay, thermal noise, gunshot noise, avalanche noise in Zener diodes, clock deviations, the temporal movements of a hard disc read head and radio noise. However, physical phenomena and tools used to measure them generally exhibit asymmetries and systematic distortions that make their results not uniformly random. A random extractor, such as a cryptographic hash function, can be used to achieve a uniform distribution of bits from a non-uniformly random source, but at a lower bit rate.
A prototype of a high-speed real-time random number generator based on a chaotic laser was developed in 2013.
Various inventive methods for collecting this entropic information have been developed. One technique is to apply a hash function to a frame of a video stream from an unpredictable source. Lavarand used this technique with images from multiple lava lamps. HotBits measured radioactive decay with Geiger-Müller tubes, while Random.org recorded fluctuations in the amplitude of atmospheric noise with a normal radio.
Computer-aided methods
Most random numbers generated by computers use PRNGs, which are algorithms that can automatically generate long sequences of numbers with good randomness properties, but eventually the sequences repeat (or the memory usage grows indefinitely). These random numbers are sufficient in many situations, but are not as random as numbers generated from electromagnetic atmospheric noise used as an entropy source. The set of values generated by such algorithms is generally determined by a fixed number called the seed. One of the most common PRNGs is the linear congruence generator, which uses the recurrence relation
Xn+1=(aXn+b)mod mX_{n+1} = (aX_n + b) \mod mXn+1=(aXn+b)modm
is used to generate numbers where aaa, bbb and mmm are large integers, and Xn+1X_{n+1}Xn+1 is the next number in a series of pseudorandom numbers. The maximum number of numbers that the formula can generate is the module mmm. The recurrence relation can be extended to matrices to have much longer periods and better statistical properties. To avoid certain non-random properties of a single linear congruence generator, several such random number generators with slightly different values of the multiplier coefficient aaa can be used in parallel, with a "master" random number generator selecting between the different generators.
A simple method for manually generating random numbers is the so-called mean square method, which was proposed by John von Neumann. Although it is easy to implement, its output is of poor quality. It has a very short period and serious weaknesses, such as the fact that the output sequence almost always converges to zero. A recent innovation is to combine the mean square method with a Weyl sequence. This method produces high quality outputs over a long period.
Most programming languages contain functions or library routines that provide random number generators. They are often designed to provide a random byte or word or a uniformly distributed floating point number between 0 and 1.
The quality, i.e. randomness, of such library functions varies widely, from completely predictable output to cryptographically secure. The standard random number generator in many languages, including Python, Ruby, R, IDL and PHP, is based on the Mersenne Twister algorithm and is not sufficient for cryptographic purposes, as explicitly stated in the language documentation. Such library functions often have poor statistical properties and some repeat patterns after only tens of thousands of trials. They are often initialised with a computer's real-time clock as a seed, since such a clock is 64-bit and measures in nanoseconds, far beyond the precision of a person. These functions may provide sufficient randomness for certain tasks (e.g. video games), but are unsuitable when high quality randomness is required, such as in cryptographic applications or statistics.
Higher-quality random number generators are available on most operating systems; for example, /dev/random on various BSD derivatives, Linux, Mac OS X, IRIX and Solaris, or CryptGenRandom for Microsoft Windows. Most programming languages, including those mentioned above, provide a way to access these higher level sources.
Generated by people
Random number generation can also be performed by humans by collecting various inputs from end users and using them as a source of randomness. However, most studies find that human subjects exhibit a certain degree of non-randomness when trying to generate a random sequence of e.g. digits or letters. They might switch between choices too often compared to a good randomiser; hence this approach is not widely used. For the same reason that humans perform poorly in this task, human random number generation can be used as a tool to gain insights into brain functions that are not accessible by other means.
Post-processing and statistical checks
Even with a plausible random number source (perhaps from a quantum mechanics-based hardware generator), it requires care to obtain completely unbiased numbers. The behaviour of these generators often changes with temperature, supply voltage, the age of the device or other external influences.
Generated random numbers are sometimes subjected to statistical tests before they are used to ensure that the underlying source still works, and are then post-processed to improve their statistical properties. An example would be the TRNG9803 hardware random number generator, which uses an entropy measurement as a hardware test and then post-processes the random sequence with a shift register stream cipher. It is generally difficult to use statistical tests to validate the generated random numbers. Wang and Nicol proposed a distance-based statistical testing technique that is used to identify the weaknesses of multiple random number generators. Li and Wang proposed a method for testing random numbers based on laser chaotic entropy sources using properties of Brownian motion.
Statistical tests are also used to provide confidence that the post-processed final output of a random number generator is truly unbiased, with numerous randomness test packages having been developed.
Further considerations
Customise distribution
Uniform distributions
Most random number generators work natively with integers or single bits, so an additional step is required to achieve the "canonical" uniform distribution between 0 and 1. The implementation is not as trivial as dividing the integer by its maximum possible value. Specifically:
- The integer used in the transformation must provide enough bits for the intended precision.
- The nature of floating point arithmetic itself means that there is more precision the closer the number is to zero. This extra precision is not normally used due to the sheer number of bits required.
- Rounding errors during division can distort the result. In the worst case, a supposedly excluded area can be drawn with real numbers, contrary to the expectations of maths.
The mainstream algorithm used by OpenJDK, Rust and NumPy is described in a proposal for the STL of C++. It does not utilise the extra precision and only suffers from distortion in the last bit due to rounding to the nearest even number. Other numerical concerns are valid if this "canonical" uniform distribution is shifted to a different range. A proposed method for the Swift programming language claims to use full precision everywhere.
Uniformly distributed integers are often used in algorithms such as the Fisher-Yates shuffle. Again, a naive implementation can introduce a modulo distortion into the result, so more elaborate algorithms must be used. A method that almost never performs division was described by Daniel Lemire in 2018, with the current state of the art being the arithmetic coding-inspired "optimal algorithm" by Stephen Canon of Apple Inc. in 2021.
Most 0 to 1 RNGs include 0 but exclude 1, while others include or exclude both.
Other distributions
Given a source of uniformly distributed random numbers, there are a few methods to create a new random source that corresponds to a probability density function. One method called the inversion method involves integrating to a range that is 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 this is the case, the x-value is accepted. Otherwise, the x-w