Random number generator principle of operation. Description: number generator for lottery

06.04.2019

On macroscopic random processes using such simple objects as dice, roulette wheel or coin, can be based generators random numbers . Chaos theory and the theory of unstable dynamical systems can explain the presence of unpredictability in data, and even macroscopic systems completely defined by Newton's equations often have unpredictable output in practice, since it depends on microscopic details of the initial conditions.

By the way, on our website you can generate a random number using the online Random Number Generator.

What is a random number generator and how does it use random physical processes?

Speed ​​of obtaining random numbers, sufficient for applied problems, cannot be provided by devices that are based on macroscopic random processes. The source of noise from which the random bits are extracted is therefore at the heart of modern AGNGs. There are two types of noise sources: those that are of a quantum nature and those that do not use quantum phenomena.

Some natural phenomena, such as the radioactive decay of atoms, are absolutely random and, in principle, cannot be predicted (the Davisson-Germer experiment can be considered one of the first experiments that prove the probabilistic nature of some phenomena), this fact is a consequence of the laws of quantum physics. And from statistical mechanics it follows that each system in its parameters has random fluctuations, if the temperature is not equal to absolute zero.

Complex random number generator.

For AGS, the "gold standard" is some of the quantum mechanical processes, since they are completely random. Using in random number generators phenomena include:

  • Shot noise is the noise that in electrical circuits is caused by discreteness of carriers electric charge and this term also refers to the noise caused in optical instruments by the discreteness of the light carrier.
  • Spontaneous parametric scattering can also be used in random number generators.
  • Radioactive decay - has the randomness of each of the individual decay events, so it is used as a source of noise. Different numbers of particles at different time intervals, as a result, fall on the receiver (this can be a Geiger counter or a scintillation counter).

It is much easier to detect non-quantum phenomena, but based on them random number generators, then they will have a strong dependence on temperature (for example, the amount of thermal noise will be proportional to the temperature environment). The following processes can be noted among those used in AGNG:

  • Thermal noise in a resistor, which after amplification produces random voltage generator. In particular, the number generator in the Ferranti Mark 1 computer was based on this phenomenon.
  • Atmospheric noise, which is measured by a radio receiver, can also include the reception of particles arriving from space to Earth, registered by the receiver, and their number will be random, at different time intervals.
  • The difference in the speed of clocks is a phenomenon that means that the rates of different clocks will not coincide at all.

To obtain from a physical random process sequence of random bits, then there are several approaches for this. One of them is that the received signal-to-noise is amplified, then filtered and fed to the input of a high-speed voltage comparator to obtain a logical signal. The duration of the comparator states will be random and this allows you to create sequence of random numbers, taking measurements of these states.

The second approach is that a random signal is applied to the input of an analog-to-digital converter (both special devices and the audio input of a computer can be used), representing a sequence of random numbers, which will result in a digitized signal and at the same time it can be processed in software .

What is a random number generator and what other phenomena does it use?

Using physical random processesrandom number generators, make it possible to obtain good random numbers, but their production is expensive and relatively difficult (especially for those ANGNs that are based on radioactive decay), but there are other more accessible sources of randomness:

Simple random number generation.

The work of digital video cameras that use the recording of macroscopic phenomena should be classified as the most unusual generators. For example, to generate random numbers, a team from Silicon Graphics used video footage of a lava lamp because the wax chaotically changes its shape in the lamp. Streams from a fan in the air stream or bubbles in an aquarium can also be used as a subject for photography.

  • Translation

Imagine it's 1995 and you're about to make your first online purchase. You open your Netscape browser and sip your coffee while home page Loads slowly. Your path lies on Amazon.com - a new online store that a friend told you about. When the stage comes to complete the purchase and enter personal data, the address in the browser changes from “http” to “https”. This signals that the computer has established an encrypted connection with the Amazon server. Now you can send data to the server credit card without fear of scammers who want to intercept information.

Unfortunately, your first online purchase was compromised from the very beginning: you will soon discover that the supposedly secure protocol used by the browser to establish a connection is, in fact, not very secure.

The problem is that the secret keys Netscape used were not random enough. They were only 40 bits long, meaning about a trillion possible combinations. It seems a large number, but hackers managed to break these codes, even on computers from the 1990s, in about 30 hours. The supposedly random number that Netscape used to generate the secret key was based on just three meanings: time of day, process ID number, and mother process ID number are all predictable. Because of this, the attacker was able to reduce the number of options for brute force and find the desired key much earlier than Netscape expected.

Netscape programmers would have loved to use completely random numbers to generate the key, but they didn't know how to get them. The reason is that digital computers are always in a precisely defined state, which changes only when a certain command is received from the program. The best you can do is to emulate randomness by generating so-called pseudo-random numbers using a special mathematical function. A set of such numbers appears to be completely random at first glance, but someone else using the same procedure could easily generate exactly the same numbers, so they are usually poor for encryption.

Researchers have managed to invent pseudorandom number generators that are found to be cryptographically secure. But they need to be started with a good random seed, otherwise they will always generate the same set of numbers. And for that initial value, you need something that is truly impossible to guess or predict.

Fortunately, it is not difficult to obtain truly unpredictable values ​​using the chaotic universe that surrounds the strictly deterministic world of computer bits on all sides. But how exactly to do this?

During recent years there is an online random number source called Lavarand. It was created in 1996 to automatically generate random values ​​by processing photographs of a decorative lamp - a lava lamp, which changes its appearance in unpredictable ways every second. Since then, random values ​​from this source have been used more than a million times.

There are also more sophisticated hardware random number generators that detect quantum effects, such as photons hitting a mirror. You can get random numbers on a regular computer by recording unpredictable events, such as the exact time you pressed a keyboard button. But to get a large number of such random values, you have to press a lot of buttons.

My colleagues and I at Intel decided that we needed to make a simpler way. That's why many of our chipsets have included an analog hardware random number generator for over a decade. The problem is that its analog circuit wastes power. In addition, it is difficult to maintain the functionality of this analog circuitry as the chip manufacturing process improves and becomes miniaturized. Therefore, we have now developed a new and completely digital system that allows the microprocessor to generate a rich stream of random values ​​without these problems. This new digital random number generator will be coming to you soon with a new processor.

Intel's first attempt making the best random number generator on regular PCs dates back to 1999, when Intel introduced the Firmware Hub component for chipsets. The chip's random number generator (PDF) is an analog ring oscillator design that senses thermal noise from resistors, amplifies it, and uses the resulting signal to vary the period of a relatively slow clock generator. For each unpredictable “tick” of this slow generator, the microcircuit imposed the oscillation frequency of a second, fast generator, which regularly changes its value between two binary states: 0 and 1. The result is an unpredictable sequence of zeros and ones.

The problem is that the ring oscillator, which is responsible for amplifying the thermal signal, consumes too much power - and it runs constantly, regardless of whether the computer needs random numbers in it or not. this moment. These analog components are also a nuisance whenever a company changes its chip manufacturing process. Every few years, the company upgrades its production lines to make chips on a smaller scale. And each time this analog fragment needs to be calibrated and tested in a new way - this complex and painstaking work has become a real headache.

That's why, in 2008, Intel set out to develop a random number generator that operates entirely on a digital basis. Researchers at the company in Hillsboro (Oregon, USA), together with engineers at the Design Lab in Bangalore (India), began to study a key problem - how to obtain a random stream of bits without using analog circuits.

Ironically, their proposed solution violates the basic rule of digital design that a circuit must always be in a specific position and return either a logical 0 or a 1. Of course, a digital element can spend short periods of time in an indeterminate position, switching between these two values. However, it must work extremely precisely and should never oscillate between them, otherwise it will cause delays or even failure in the system. In our random bit generator, fluctuations are a feature, not a bug.

Our previous analog generator was only capable of producing a couple hundred kilobits of random numbers per second, while the new one generates them at a rate of about 3 Gb/s. It starts out by collecting the nearly random values ​​of the two inverters in 512-bit blocks. These blocks are subsequently divided into pairs of 256-bit numbers. Of course, if the original 512 bits are not completely random, these 256 bit numbers won't be completely random either. But they can be mathematically combined to produce a 256-bit number that is close to ideal.


THREE LEVELS OF NUMBERS: The Intel Bull Mountain Random Number Generator prevents any variation in predictability through a three-step process. First, the digital circuit generates a stream of random bits. Then the “normalizer” (conditioner) generates good random seeds based on this stream. In the third stage, the pseudorandom number generator produces a stream of digits for use in software.

All this is better illustrated by a simple illustration. Assume for a second that the random bit generator produces 8-bit patterns, that is, numbers in the range from 0 to 255. Also assume that these 8-bit numbers are not completely random. Now imagine that, for example, some subtle flaw in the circuit shifts the output values ​​to the lower part of the range. At first glance, the stream of random numbers seems good, but if you process millions of values, you will notice that the numbers at the top of the range are slightly less common than the numbers at the bottom.

One possible solution to this problem is simple: always take a pair of 8-bit numbers, multiply them, and then discard the top eight bits of the resulting 16-bit number. This procedure will eliminate the distortion almost completely.

Bull Mountain does not work with 8-bit numbers: it works, as already stated, with 256-bit numbers. And it does not multiply them, but performs more complex cryptographic operations. But the basic idea is the same. You can think of this step as "normalization" to eliminate any deviations from the random distribution of numbers that can occur in a circuit with two inverters.

We really want to sleep well at night, so we designed additional circuitry that tests the streams of 256-bit numbers that go into the “normalizer” so that they are not too skewed in one direction. If this is found, we mark it as defective and not up to standard. Thus, operations are performed only with high-quality pairs of numbers.

Guaranteed randomness is not enough if random values ​​are not produced fast enough to meet the standards. Although the hardware loop generates thread much faster than its predecessors, it is still not enough for some modern tasks. So that Bull Mountain can produce random numbers as quickly as software pseudo-random number generators produce a stream, but at the same time save high quality random numbers, we added one more level to the scheme. Here, 256-bit random numbers are used as cryptographically secure random seeds to generate large quantity pseudorandom 128-bit numbers. Since 256-bit numbers are delivered at 3 GHz, there is enough material guaranteed to generate cryptographic keys quickly.

The new instruction, called RdRand, allows a program that needs random numbers to make a request to the hardware that produces them. Designed for 64-bit Intel processors, the RdRand instruction is the key to the Bull Mountain generator. It extracts 16-, 32-, or 64-bit random values ​​and places them in a program-accessible register. The RdRand instruction manual was made available to the public about a year ago, and the first Intel processor to support it will be Ivy Bridge. The new chipset is 37% faster than its predecessor, and the size of its minimum elements has been reduced from 32 to 22 nanometers. The overall performance increase fits well with the needs of our random number generator.

Although lava lamps look cool, they will not fit into every interior. We think that our approach to generating random numbers, on the contrary, will find the most universal application.

As already mentioned, recording the exact timing of keypresses has been used as a convenient source of random starting values ​​for generators in the past. For the same purposes, we used mouse movements and even the speed of searching sectors on the hard drive. But such events don't always give you enough random bits, and after a certain time of measurement, these bits become predictable. Worse, since we now live in a world of servers with

Every day, more and more people are interested in online casinos. For some, these games are simply entertainment, while others consider them a means of earning money. Probably each of the players will be interested in how the random number generator works, which produces lucky combinations.

Slot machine device

Modern slot machines http://igrat-avtomati-wulcan.com have a rather complex algorithm that produces winning combinations. It can be divided into parts: Sensors in the form of generators, a counter that accepts payment and gives out winnings, a storage system for big prizes in the form of a jackpot, an algorithm in the form of a kernel for issuing winning funds. These Algorithms are formed into a mechanical structure in the form of slots or roulette.

Sensor of random combinations and numbers. (RNG)

Now we can describe the operation of the RNG itself. Such sensors were developed with the intention of making the game as unpredictable as possible. This scheme works due to an equally probable factor, for example, it stops the ball in different holes on the roulette wheel. With slots, the system works exactly the same, only it stops the symbols.

In modern gaming slot, the developer can install more than one RNG. If we take the game three sevens as an example, there may be several sensors for individual combinations, as well as separate species sensor to stop the numbers of a digital wheel or drum.

In Games like Polka Miracles, sensors are installed to stop the numbers in the game, as well as sensors that calculate the time interval of each game and record the transition to others playing fields. The use of more than one sensor is intended to reduce the number of random wins. Also, for large prizes in the form of jackpots, separate sensors are usually installed that give winning combination by chance that cannot be calculated.

If we consider a random number generator from a mathematical point of view, it is impossible to calculate its operation using various formulas. However, if you take into account an already winning situation, and carry out calculations from the beginning of one game to the end, then you can still write the formula. It's sad that after the jackpot is issued, numbers will continue to be generated. new formula, which will be known only by the outcome of the game.

There is also an opinion that the owner of the machine can configure the sensor settings in such a way that each winning slot will appear, conditionally, every 300 or 500 games, however, the owner himself cannot know exactly how many derived algorithms will result in an exact win. But the fact that the sensors are adjustable is a fact. In order to avoid a conflict of interest, they install not one sensor, but several, otherwise the owner of the gambling house would always remain in the black, and otherwise the sensor could be figured out by any skilled person and clear the casino cash register in an almost legal way.

The principle of operation of the random number generator is known for its unpredictability, however, it is at least somewhat amenable to analysis, but coupled with a couple more sensors, everything becomes much more confusing, which makes the casino a gambling success, which is why it is extremely popular all over the world.

What is randomness in a computer? How are random numbers generated? In this article we have tried to provide simple answers to these questions.

In software, and in technology in general, there is a need for reproducible randomness: numbers and pictures that appear random are actually generated by a specific algorithm. This is called pseudorandomness and we will look at simple ways creating pseudorandom numbers. At the end of the article, we will formulate a simple theorem for generating these seemingly random numbers.

Determining what exactly constitutes an accident can be quite challenging. There are tests (like Kolmogorov complexity) that can give you exact value how random a particular sequence is. But we won't bother, we'll just try to create a sequence of numbers that will seem unrelated to each other.

Often what is needed is not just one number, but several random numbers generated continuously. Therefore, given initial value, we need to create other random numbers. This initial value is called seed, and we'll see how to get it later. For now, let's focus on creating other random values.

Generating Random Numbers from a Seed

One approach might be to apply some crazy math formula to the seed, then twist it so much that the output number seems unpredictable, and then take that as the seed for the next iteration. The only question is what this distortion function should look like.

Let's experiment with this idea and see where it takes us.

The distortion function will take one value and return another. Let's call it R.

R(Input) -> Output

If the value of our seed is 1, then R will create a series of 1, 2, 3, 4,... This doesn't look random at all, but we'll get there. Let R now add a constant instead of 1.

R(x) = x + c

If c equals, for example, 7, then we get the series 1, 8, 15, 22, ... Still not the same. Obviously, what we are missing is that the numbers should not only increase, they should be spread out over some range. We need our sequence to return to the beginning - a circle of numbers!

Number circle

Let's look at the clock face: our row starts at 1 and goes around in a circle until 12. But since we are working with a computer, let's let there be 0 instead of 12.

Now starting from 1 we will again add 7. Progress! We see that after 12 our series begins to repeat, no matter what number we start with.

Here we get a very important property: if our loop consists of n elements, then the maximum number of elements that we can get before they start repeating is n.

Now let's rewrite the R function to match our logic. You can limit the length of a loop using the modulus operator or the remainder operator.

R(x) = (x + c) % m

R (x) = (x + c) % m

At this point you may notice that some numbers do not fit into c. If c = 4 and we started at 1, our sequence would be 1, 5, 9, 1, 5, 9, 1, 5, 9, ... which of course doesn't work for us, because this sequence is absolutely not random. It becomes clear that the numbers we choose for the loop length and the jump length must be related in a special way.

If you try a few different meanings, then you can see one property: m and c must be relatively prime.

So far we've been making leaps by adding, but what if we use multiplication? Let's multiply X to a constant a.

R(x) = (ax + c) % m

R (x) = (ax + c) % m

Properties that a must obey in order to be formed full cycle, are a little more specific. To create a valid loop:

  1. (a - 1) must be divisible by all prime factors m
  2. (a - 1) must be divisible by 4 if m is divisible by 4

These properties, together with the rule that m and c must be relatively prime, constitute the Hull-Dobell theorem. We won't look at its proof, but if you took a bunch of different values ​​for different constants, you could come to the same conclusion.

Seed selection

Now it's time to talk about the fun part: choosing the initial seed. We could make it a constant. This can be useful in cases where you need random numbers, but you want them to be the same every time you run the program. For example, creating the same map for each game.

Another way is to get a seed from a new source every time the program is started, like a system clock. This is useful when you need a total random number, as in a dice rolling program.

Final result

When we apply a function to its result several times, we get a recurrence relation. Let's write our formula using recursion.

Have you ever checked the statement that out of 10 spins of roulette, an even number comes up 5 times? Or maybe you have participated in lotteries several times and even managed to win? If we accept that all results are truly random, then we can talk about the probability of the occurrence of a particular event.

To paraphrase the last statement, let us repeat the words of people who have been participating in events with random results for months: the almighty random works.

So how can you check whether the distribution principle is random? A random number generator will handle this task. Its main advantage is that it works online, which means it is very fast and does not depend on the presence of an Internet connection after downloading.

How does a random number generator work?

To describe the work, you don’t need many letters, everything is very simple: you need to select the minimum and maximum possible numbers, enter the number of generated values, if necessary, check the “Exclude repetitions” checkbox, which prevents the appearance of numbers that have already existed, and click the generate button. After this, each subsequent click of the button will produce new distribution options.

Why might this be needed? For example, to get lucky numbers in the lottery or roulette. In addition, the pseudo-random number generator is able to emulate lotto barrels or a coin toss for a competition - heads and tails are represented by zero or one. But the main thing is that after loading the page you do not need an Internet connection - the code is written in JavaScript and executed on the user's side, in his browser.

Testing the operation of this online generator sometimes gave very interesting results: using the numbers 0 and 1, with 10 options, not so rarely produced a distribution in the ratio of 7 to 3, or even 6 identical numbers in a row.

For what else, besides lotto and the examples above, can random be useful for distributing numbers? At least for the guessing game. You probably played this game in childhood: the host guesses a number from 1 to 100, and the others try to guess it. In relation to this generator, you act as the leader, and the computer tries to guess what is hidden.

You can even play Sea battle, immediately receiving a group of numbers in the range from 0 to 99. In this case, the most significant digit of the number is used as letters (which are indicated horizontally) - 0...9 is a...and, the low digits in this case replace the range 1...10, then there is just one added. Perhaps now this approach does not seem very clear, but it is a matter of habit.

Another interesting way use - check your intuition. You try to predict which numbers (one by one or in a group) the generator will produce, press a button and check how close you were to the correct result. Who knows, maybe after several attempts you will be able to accurately predict the outcome?

But it should be taken into account that the random number generator is called that for a reason. Existing methods today are not able to provide a truly random value - it depends on many factors, which may include the previous number, the current time, the contents of a particular memory cell and other data. But for domestic needs, their functionality is usually 100% sufficient.

Well, I hope that you will find more extensive use for the generator than the options described here. And maybe you can even suggest good idea to expand existing functionality. In the end, it was the most incredible thoughts that eventually turned from a vague idea into a real embodiment.



Similar articles