Any number from 1 to 15. Excel random number generator in functions and data analysis

Any number from 1 to 15. Excel random number generator in functions and data analysis
Any number from 1 to 15. Excel random number generator in functions and data analysis

Generator Description

Our free online generator is designed to generate random integers. It can be easily used, for example, to determine the winning number of your lottery, the winner of a drawing or competition.

The number of simultaneously generated numbers: from 1 to 999. By default, one number is generated.

The available range of numbers is from 1 to 99,999,999 inclusive. In this case, the final value of the range must be greater than the initial value. By default, the range from 1 to 100 is used to generate a random number.

The generated numbers can be sorted: random (default), descending, and ascending.

When displaying numbers in the result block, you can use separators: space (default), comma, and the combination "comma + space".

When generating multiple numbers, the same may appear. Dubs are removed by default. If you admit the presence of the same numbers as a result, then simply remove the bird in the field "Repetition of numbers".

The generator also allows you to copy the result to the clipboard. To do this, you need to use the "Copy" button, the result will be automatically placed on the clipboard.

If you need to return the values ​​of all fields to their original state, press the "Reset" button.

A few words about accidents

As surprising as it may be for an ordinary person, random numbers play a very important role in a wide variety of areas of human activity, where sequences of random numbers are required, which no one can predict. The best known examples are lotteries or online casinos. After all, if such sequences turn out to be not entirely random and someone can trace the order in them, he can calmly apply this knowledge to his own interests. So in 1873, the British engineer Joseph Jagger, along with six of his assistants, went to the casino and began to write down the numbers on the roulette wheels. Imagine, but he found that on one of the roulette wheels some numbers appear much more often than others, i.e. are not so random! It was then that he began to bet money on these numbers. And although the owners of the casino suspected that something was wrong and tried to somehow rectify the situation by rearranging the tables from place to place, it did not help them. Jagger won a total of about $ 5 million from them at the current rate.

You also need random numbers in cryptography, for example, to encrypt network traffic or carry out banking transactions. If the generated sequences of random numbers have easily detectable patterns, attackers can intercept outgoing traffic and harm the user's computer or steal his confidential data.

In addition, random numbers are used in various scientific and engineering fields for computer modeling of real natural processes, in statistics, which itself is based on chances, in various gambling games (not only does roulette require randomness), etc.

As you can see, accidents are in demand. But is it easy to get really high quality random sequences of numbers or symbols? Let's say right away that it is theoretically possible to create such a generator, but it is very difficult to do it in practice. That is why numbers obtained using various mathematical algorithms are called pseudo-random. There are many varieties of pseudo-random number generators that use the most sophisticated algorithms, but they are still not perfectly random. However, the more different initial conditions that make it difficult to predict each subsequent sequence number used in the generator, the more reliable it is.

So where do the truly random events take place? At the moment, science believes that the events of quantum mechanics should be considered random. According to the Heisenberg uncertainty principle, we cannot measure all the necessary parameters of a quantum object with any great accuracy. Moreover, in principle we cannot, and not because we do not have enough technical capabilities. And since it is impossible to measure all the initial parameters, then the exact outcome of the process cannot be predicted either.

Thus, quantum generators should be considered the best quality random number generators, i.e. those that use quantum processes in their work.

We have a sequence of numbers consisting of practically independent elements that obey a given distribution. Usually evenly distributed.

There are different ways and methods to generate random numbers in Excel. Consider only the best ones.

Random number function in Excel

  1. The RAND function returns a random, evenly distributed real number. It will be less than 1, greater than or equal to 0.
  2. The RANDBETWEEN function returns a random integer.

Let's consider their use by examples.

Sampling random numbers with RAND

This function does not require any arguments (RAND ()).

To generate a random real number in the range from 1 to 5, for example, we apply the following formula: = RAND () * (5-1) +1.

The returned random number is evenly distributed over the interval.

Each time the worksheet is calculated or a value changes in any cell in the worksheet, a new random number is returned. If you want to keep the generated population, you can replace the formula with its value.

  1. We click on a cell with a random number.
  2. In the formula bar, select the formula.
  3. Press F9. AND ENTER.

Let's check the uniformity of the distribution of random numbers from the first sample using the distribution histogram.


The range of vertical values ​​is frequency. Horizontal - "pockets".



RANDBETWEEN function

The syntax for the RANDBETWEEN function is (lower bound; upper bound). The first argument must be less than the second. Otherwise, the function will throw an error. The boundaries are assumed to be integers. The formula discards the fractional part.

An example of using the function:

Random numbers with precision 0.1 and 0.01:

How to make a random number generator in Excel

Let's make a random number generator with the generation of a value from a certain range. We use a formula of the form: = INDEX (A1: A10; INT (RAND () * 10) +1).

Let's make a random number generator in the range from 0 to 100 with a step of 10.

Choose 2 random values ​​from the list of text values. Using the RAND function, let's compare text values ​​in the range A1: A7 with random numbers.

Let's use the INDEX function to select two random text values ​​from the original list.

To select one random value from the list, apply the following formula: = INDEX (A1: A7; RANDBETWEEN (1; COUNT (A1: A7))).

Normal distribution random number generator

The RAND and RANDBETWEEN functions produce random numbers with a uniform distribution. Any value with equal probability can fall into the lower border of the requested range and into the upper one. This results in a huge spread from the target value.

Normal distribution implies that most of the generated numbers are close to the target. Let's correct the formula RANDBETWEEN and create a data array with normal distribution.

The cost of goods X is 100 rubles. The entire batch produced is subject to normal distribution. The random variable also obeys a normal probability distribution.

Under these conditions, the average value of the range is 100 rubles. Let's generate an array and build a graph with a normal distribution with a standard deviation of 1.5 rubles.

We use the function: = NORMINV (RAND (); 100; 1.5).

Excel calculated which values ​​are in the range of probabilities. Since the probability of producing a product with a cost of 100 rubles is maximum, the formula shows values ​​close to 100 more often than others.

Let's move on to building a graph. First you need to create a table with categories. To do this, let's split the array into periods:

Based on the data obtained, we will be able to form a diagram with a normal distribution. The value axis is the number of variables in the interval, the category axis is the periods.

To generate random numbers in the range you need, it is best to use the Online Random Number Generator. The presence of a large number of options will allow you to select the required number of random numbers, as well as specify the final and initial value.

Online number generator (randomizer) instruction:

The default random number generator is 1 number. If you change the application settings, you can generate up to 250 random numbers at the same time. First, you need to set a range. The maximum value for a number is 9,999,999,999. The random number generator allows you to sort the numbers in descending, ascending or random order.

To display the result, you can use different separators: semicolon, comma, and space. In addition, repetitions may occur. The "Exclude duplicates" option will allow you to get rid of dubbing. You can also send a link to the calculations made by messenger or e-mail by copying the "Link to the result".

Numbers surround us from birth and play an important role in life. For many people, the work itself is connected with numbers, someone relies on luck, filling lottery tickets with numbers, and someone gives them a completely mystical meaning. One way or another, sometimes we cannot do without using a program such as random number generator.

For example, you need to organize a prize drawing among the subscribers of your group. Our online random number generator will help you quickly and honestly choose the winners. You just need, for example, to set the required number of random numbers (by the number of winners) and the maximum range (by the number of participants, if they are assigned numbers). Fraud in this case is completely excluded.

This program can also serve as a lotto random number generator. For example, you bought a ticket and want to rely entirely on randomness and luck in choosing the numbers. Then our number randomizer will help you fill out your lottery ticket.

How to generate a random number: instructions

Random number program works very simply. You don't even need to download it to your computer - everything is done in the browser window where this page is open. Random numbers are generated in accordance with the specified number of numbers and their range - from 0 to 999999999.

To generate a number online, you need:

  1. Select the range in which you want to get the result. Perhaps you want to truncate numbers to 10 or, say, 10,000;
  2. Exclude repetitions - by selecting this item, you will force the ** number randomizer ** to offer you only unique combinations within a certain range;
  3. Select the number of numbers - from 1 to 99999;
  4. Press the button "Generate numbers".

No matter how many numbers you want to get as a result, the prime number generator will give the whole result at once and you can see it on this page, flipping through the field with numbers using the mouse or touchpad.

Now you can use the ready-made numbers as you need it. From the field with numbers, you can copy the result for posting in a group or sending by mail. And so that no one doubts the result, take a screenshot of this page, on which the parameters of the number randomizer and the results of the program will be clearly visible. It is impossible to change the numbers in the field, so the possibility of juggling is excluded. We hope our website and random number generator helped you.

Have you ever wondered how Math.random () works? What is a random number and how is it obtained? Imagine a job interview question - write your random number generator in a couple of lines of code. So, what is it, an accident and is it possible to predict it?

I am very interested in various IT puzzles and tasks and a random number generator - one of these tasks. Usually, in my telegram channel, I sort out all sorts of puzzles and different tasks from interviews. The problem about the random number generator has gained great popularity and I wanted to immortalize it in the bowels of one of the authoritative sources of information - that is, here, on Habré.

This material will be useful to all those front-end developers and Node.js developers who are at the cutting edge of technology and want to get into a blockchain project / startup, where questions about security and cryptography, at least at a basic level, are even asked from front-end developers.

Pseudo-random number generator and random number generator

In order to get something random, we need a source of entropy, a source of some chaos from which we will use to generate randomness.

This source is used to accumulate entropy with the subsequent receipt of an initial value (seed) from it, which is necessary for random number generators (RNG) to generate random numbers.

The Pseudo-Random Number Generator uses a single seed, hence its pseudo-randomness, while the Random Number Generator always generates a random number, having a high-quality random variable at the beginning, which is taken from various sources of entropy.

Entropy is a measure of disorder. Information entropy is a measure of the uncertainty or unpredictability of information.
It turns out that in order to create a pseudo-random sequence, we need an algorithm that will generate a certain sequence based on a certain formula. But such a sequence can be predicted. Nevertheless, let's fantasize how we could write our own random number generator if we didn't have Math.random ()

PRNG has some algorithm that can be reproduced.
RNG is getting numbers completely from any noise, the ability to calculate which tends to zero. At the same time, the RNG has certain algorithms for equalizing the distribution.

Coming up with our own PRNG algorithm

A pseudorandom number generator (PRNG) is an algorithm that generates a sequence of numbers whose elements are almost independent of each other and obey a given distribution (usually uniform).
We can take a sequence of some numbers and take from them the modulus of the number. The simplest example that comes to mind. We need to think about which sequence to take and the module from which. If you just head-on from 0 to N and modulus 2, then you get generator 1 and 0:

Function * rand () (const n = 100; const mod = 2; let i = 0; while (true) (yield i% mod; if (i ++> n) i = 0;)) let i = 0; for (let x of rand ()) (if (i ++> 100) break; console.log (x);)
This function generates for us the sequence 01010101010101 ... and you can't even call it pseudo-random. For a generator to be random, it must pass the test for the next bit. But we do not have such a task. Nevertheless, even without any tests, we can predict the next sequence, which means that such an algorithm does not fit head-on, but we are in the right direction.

And what if we take some well-known but non-linear sequence, for example, the number PI. And as the value for the module, we will take not 2, but something else. You might even think about the changing meaning of the module. The sequence of digits in the number Pi is considered random. The generator can operate using pi numbers starting from some unknown point. An example of such an algorithm, with a PI-based sequence and with a mutable module:

Const vector = [... Math.PI.toFixed (48) .replace (".", "")]; function * rand () (for (let i = 3; i<1000; i++) { if (i >99) i = 2; for (let n = 0; n But in JS, the PI number can only be displayed up to 48 characters and no more. Therefore, it is still easy to predict such a sequence, and each run of such a generator will always produce the same numbers. But our generator has already started showing numbers from 0 to 9.

We got a generator of numbers from 0 to 9, but the distribution is very uneven and it will generate the same sequence every time.

We can take not the number Pi, but the time in numerical representation and consider this number as a sequence of digits, and in order to prevent the sequence from repeating each time, we will read it from the end. In total, our algorithm for our PRNG will look like this:

Function * rand () (let newNumVector = () => [... (+ new Date) + ""]. Reverse (); let vector = newNumVector (); let i = 2; while (true) (if ( i ++> 99) i = 2; let n = -1; while (++ n< vector.length) yield (vector[n] % i); vector = newNumVector(); } } // TEST: let i = 0; for (let x of rand()) { if (i++ >100) break; console.log (x))
This already looks like a pseudo-random number generator. And the same Math.random () is a PRNG, we will talk about it a little later. Moreover, each time the first number is different.

Actually, using these simple examples, you can understand how more complex random number generators work. And there are even ready-made algorithms. For example, let's look at one of them - this is Linear Congruent PRNG (LCPRNG).

Linear congruent PRNG

Linear Congruential PRNG (LCPRNG) is a common technique for generating pseudo-random numbers. It is not cryptographically strong. This method consists in calculating the members of a linear recurrent sequence modulo some natural number m given by the formula. The resulting sequence depends on the choice of the starting number - i.e. seed. Different seed values ​​produce different sequences of random numbers. An example of implementing such an algorithm in JavaScript:

Const a = 45; const c = 21; const m = 67; var seed = 2; const rand = () => seed = (a * seed + c)% m; for (let i = 0; i<30; i++) console.log(rand())
Many programming languages ​​use LCPRNG (but not exactly such an algorithm (!)).

As mentioned above, this sequence is predictable. So why do we need a PRNG? When it comes to security, PRNG is a problem. If we talk about other tasks, then these properties can play a plus. For example, for various special effects and graphics animations, you may need to call random frequently. And this is where the distribution of meanings and performance are important! Secondary algorithms cannot boast of the speed of work.

Another property is reproducibility. Some implementations allow you to set a seed, which is very useful if the sequence needs to be repeated. Reproduction is needed in tests, for example. And there are many other things out there that don't need a secure RNG.

How Math.random () works

The Math.random () method returns a pseudo-random floating point number from the range = crypto.getRandomValues ​​(new Uint8Array (1)); console.log (rvalue)
But, unlike PRNG Math.random (), this method is very resource intensive. The fact is that this generator uses system calls in the OS to get access to sources of entropy (mac address, cpu, temperature, etc ...).