How does a random number generator work? Checking the quality of the generator

All phenomena that happen to us are of two types - random and natural. For example, you didn’t have enough bills to buy a tape recorder, and you decided to buy a player - i.e. the action is logical and expected. But as you walk to the store, you discover the required amount, which randomly changed plans. Generator operation random numbers completely depends on the mechanism specified in the operator, so that all numbers that are issued are pseudo-random in the current event. Operators that return random numbers, refer to time, namely system time. Those. Both in the world and in programming, nothing is completely absolute.

rand function

In C programming, built-in operators were invented to obtain random values, which give us the required results. And so, to create a random number, use rand function, which rand operator used to obtain random numbers that return a range from 0 to a certain constant. Moreover, this constant is declared in the system directive “stdlib.h”, where this rand function is based. The syntax of this function is simple: int m= rand(); those. an integer is returned. After testing the operator in practice, you will see that the numbers that appear when the application starts are identical. The oversight is that the rand operator works with the same system time, which was preserved during compilation. This random number generator is tied to an algorithm for changing the program time, but everything works incorrectly.

Now about srand and random

For this problem, a function that would reset the built-in time to zero every time the rand operator was called was indispensable, and the software developers did srand function. The action allows the rand function to access each time not the installed timer, but the current built-in timer, which opens up the ability for the generator to work correctly - to produce random values. Recently, in C++ programming, the mechanism for issuing random numbers has been improved due to the appearance of microseconds. In addition, the range of values ​​​​has expanded, and all current innovations have been transformed into the random function.

Etc., and is used by account owners to attract new audiences to the community.

The result of such drawings often depends on the user's luck, since the recipient of the prize is determined randomly.

To make this determination, lottery organizers almost always use an online or pre-installed random number generator that is distributed free of charge.

Choice

Quite often, choosing such a generator can be difficult, since their functionality is quite different - for some it is significantly limited, for others it is quite wide.

Enough is being implemented a large number of such services, but the difficulty is that they differ in scope.

Many, for example, are tied in their functionality to a certain social network(for example, many generator applications only work with links from this one).

Most simple generators they simply randomly determine a number within a given range.

This is convenient because it does not associate the result with a specific post, which means it can be used for sweepstakes outside the social network and in various other situations.

They essentially have no other use.

Advice! When choosing the most suitable generator, it is important to consider what it will be used for.

Specifications

For the fastest process of choosing the optimal online random number generation service, the table below shows the main specifications and functionality of such applications.

Table 1. Features of operation online applications to generate a random number
Name Social network Multiple results Select from a list of numbers Online widget for the site Select from a range Disabling repetitions
RandStuff Yes Yes No Yes No
Cast Lots Official website or VKontakte No No Yes Yes Yes
Random number Official site No No No Yes Yes
Randomus Official site Yes No No Yes No
Random numbers Official site Yes No No No No

All applications discussed in the table are described in more detail below.

RandStuff

You can use this application online by following the link to its official website http://randstuff.ru/number/.

This is a simple random number generator, characterized by fast and stable operation.

It is successfully implemented both in the format of a separate stand-alone application on the official website, and as an application in .

The peculiarity of this service is that it can select a random number both from a specified range and from a specific list of numbers that can be specified on the site.

  • Stable and fast work;
  • Lack of direct connection to a social network;
  • You can select one or several numbers;
  • You can only choose among the specified numbers.

User reviews about this application are as follows: “We determine winners in VKontakte groups through this service. Thank you,” “You are the best,” “I only use this service.”

Cast Lots

This application is a simple function generator, implemented on the official website in the form of a VKontakte application.

There is also a generator widget for inserting into your website.

The main difference from the previous described application is that this allows you to disable the repetition of the result.

Random numbers are a simple element of cryptography that is the least talked about, but is just as important as the rest. Almost all computer security systems that use cryptography require random numbers - for keys, unique numbers in protocols, etc. - and the security of such systems often depends on the randomness of its random numbers. If the random number generator is unreliable, the entire system breaks down.

Depending on who you talk to, generating random numbers looks either trivial or impossible. Theoretically this is impossible. John von Neumann, father computer technology, said: "Anyone who believes that there are arithmetic methods for obtaining random numbers"is certainly sinning." He meant that it is impossible to get something random in in every sense words are the output of such a deterministic beast as a computer. This is true, but fortunately there are some things we can do. What we need from a random number generator is not that the numbers are truly random, but that they cannot be predicted and reproduced. If we have these two conditions met, we can achieve security.

On the other hand, if we violate these two conditions, there is no security. In 1994, a computer random number generator for lotteries was installed in a Montreal casino. One observant player who spent a lot of time in the casino noticed that winning numbers were the same every day. He successfully hit three Jackpots in a row and received $600,000. (After wringing their hands, gnashing their teeth and investigating everything, the casino paid the winnings.)

There are several broad classes of random number generators. Some of them are based on physical processes that can be considered quite random. The National Security Agency likes to use electrical noise from diodes in its equipment to create random numbers. Other possibilities are Geiger counters or radio interference receivers. One system on the Internet uses a digital camera pointed at several strobes. Other systems use air turbulence in the drives or the timing of network packets.

Some random number generators track the user's random movements. The program may ask the user to type a large string of arbitrary characters on the keyboard; it can use a sequence of characters or even the time between keystrokes to generate random numbers. Another program can easily require the user to move the mouse back and forth or grunt into the microphone.

Some random number generators apply this entered information without modification. In others, it serves as a seed (initial number) for mathematical random number generators. This technique works best if the system requires more random numbers than the input provides.

Whatever the origin of the randomness, the generator will create a series of random bits. They can then be used as cryptographic keys and for everything else the system needs.

On macroscopic random processes using such simple objects as dice, roulette wheel or coin, can be based random number generators. The theory of chaos and the theory of unstable dynamic systems it is possible to explain the presence of unpredictability in the 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 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 is caused in electrical circuits by the discreteness of electric charge carriers 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. A different number of particles at different time intervals, as a result, hits 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.

Many lottery participants do not want to waste time on selection winning combination and filling out a lottery ticket.

To help them, most specialized lottery sites offer a very convenient “Automatic Dial” function. Today we will tell you what it is and how it works.

"Automatic Dialing"

This function is a classic random number generator, invented since the founding of the first lottery sites and virtual casinos. More than 70% of buyers of virtual tickets for foreign lotteries choose this absolutely free option.

In addition, you can automatically select not just one winning combination, but several (up to 50). This is very convenient for players who buy a large number of lottery tickets with different rates.

Winning statistics

If you are still in doubt whether to use the “Automatic Dial” function or bother filling out tickets yourself, read on. Reviews of the Euromillions lottery from its winners clearly state that the difference in the methods of filling out the ticket does not in any way affect the participant’s chances. This also tells us lottery statistics, according to which, from total number Players who use this option on Internet sites receive a winnings of about 70%. In order not to be unfounded, we will give examples of lucky winners in 2012 who made bets using a computer.

In March 2012, a US couple won a huge jackpot of $218 million in the New York lottery. They did not develop a lottery strategy (read section Gaming Strategies), but simply used the “Automatic dial” function.

Winners of the record drawing of the American national lottery PowerBall, who split $586 million equally, filled their tickets using a random number generator.

An elderly lady, who did not want to think about the winning combination, entrusted the selection of numbers to a computer and won 336 million US dollars.

Pros of a random number generator

The first indisputable advantage of using this function is significant time savings. With one click you can place several bets at once for one draw of any foreign lottery.

The second advantage is that it eases the player's mental efforts to create a winning combination. If you are not a numerology fanatic and do not believe in the magic of numbers, believe me, better than a computer You can’t come up with a combination of numbers.

The third fact in favor of “Automatic Dial” is absolutely equal chances of winning the jackpot and other big prize With lottery tickets filled in with your own hand.