# Random Number Generator

Use this generator to get a trully random, cryptographically safe number. It generates random numbers that can be used where unbiased results are critical, such as when shuffling a deck of cards for a poker game or drawing numbers for a lottery, giveaway, or sweepstake.

## How to pick a random number between two numbers?

You can use this random number generator to pick a truly random number between any two numbers. For example, to get a **random number between 1 and 10**, including 10, enter 1 in the first field and 10 in the second, then press "Get Random Number". Our randomizer will pick a number from 1 through 10 at random. To generate a random number between 1 and 100, do the same, but with 100 in the second field of the picker. To **simulate a dice roll**, the range should be 1 to 6 for a standard six-sided dice.

To generate more than one unique number, just select how many you need from the drop-down below. For example, selecting to draw 6 numbers out of the set of 1 to 49 possible would be equivalent to simulating a lottery draw for a game with these parameters.

## Where are random numbers useful?

You might be organizing a charity lottery, a giveaway, a sweepstakes, etc. and you need to draw a winner - this generator is for you! It is **completely unbiased and outside of your control**, so you can assure your crowd of the fairness of the draw, which might not be true if you are using standard methods like rolling a dice. If you need to choose several among the participants instead, just select the number of unique numbers you want generated by our random number picker and you are all set. However, it is usually best to draw the winners one after another, to keep the tension for longer (discarding repeat draws as you go).

A random number generator is also useful if you need to decide **who goes first** in some game or activity, such as board games, sport games and sports competitions. The same is true if you need to decide the **participation order** for multiple players / participants.

Nowadays, a number of government-run and private lotteries and lottery games are using software RNGs instead of more traditional drawing methods. RNGs are also used to determine the outcomes of all modern slot machines.

Finally, random numbers are also useful in statistics and simulations, where they might be generated from distributions different than the uniform, e.g. a normal distribution, a binomial distribution, a power distribution, pareto distribution... For such use-cases a more sophisticated software is required.

## Generating a random number

There is a philosophical question about **what exactly "random" is**, but its defining characteristic is surely **unpredictability**. We cannot talk about the unpredictability of a single number, since that number is just what it is, but we can talk about the unpredictability of a series of numbers (number sequence). If a sequence of numbers is random, then you should not be able to predict the next number in the sequence while knowing any part of the sequence so far. Examples for this are found in rolling a fair dice, spinning a well-balanced roulette wheel, drawing lottery balls from a sphere, and the classic **flip of a coin**. No matter how many dice rolls, coin flips, roulette spins or lottery draws you observe, you do not improve your chances of guessing the next number in the sequence. For those interested in physics the classic example of random movement is the Browning motion of gas or fluid particles.

Given the above and knowing that computers are fully deterministic, meaning that their output is completely determined by their input, one might say that we cannot generate a random number with a computer. However, one will only partially be true, since a dice roll or a coin flip is also deterministic, if you know the state of the system.

The randomness in our number generator comes from physical processes - our server gathers environmental noise from device drivers and other sources into an **entropy pool**, from which random numbers are created ^{[1]}.

### Sources of randomness

According to Alzhrani & Aljaedi ^{[2]} there are four sources of randomness that are used in the seeding of a generator of random numbers, two of which are used in our number picker:

- Entropy from the disk when the drivers call it - gathering seek time of block layer request events.
- Interrupt events from USB and other device drivers
- System values such as MAC addresses, serial numbers and Real Time Clock - used only to initialize the input pool, mostly on embedded systems.
- Entropy from input hardware - mouse and keyboard actions (not used)

This puts the RNG we use in this random number software in compliance with the recommendations of RFC 4086 on randomness required for security ^{[3]}.

## True random versus pseudo random number generators

A **pseudo-random number generator (PRNG)** is a finite state machine with an initial value called the **seed** ^{[4]}. Upon each request, a transaction function computes the next internal state and an output function produces the actual number based on the state. A PRNG deterministically produces a periodic sequence of values that depends only on the initial seed given. An example would be a linear congruential generator like PM88. Thus, knowing even a short sequence of generated values it is possible to figure out the seed that was used and thus - know the next value.

A **cryptographic pseudo-random number generator (CPRNG)** is a PRNG in that it is predictable if the internal state is known. However, assuming the generator was seeded with sufficient entropy and the algorithms have the needed properties, such generators will not quickly reveal significant amounts of their internal state, meaning that you would need a huge amount of output before you can mount a successful attack on them.

A hardware RNG is based on unpredictable physical phenomenon, referred to as **"entropy source"**. Radioactive decay, or more precisely the points in time at which a radioactive source decays is a phenomenon as close to randomness as we know, while decaying particles are easy to detect. Another example is heat variation - some Intel CPUs have a detector for thermal noise in the silicon of the chip that outputs random numbers. Hardware RNGs are, however, often biased and, more importantly, limited in their capacity to generate sufficient entropy in practical spans of time, due to the low variability of the natural phenomenon sampled. Thus, another type of RNG is needed for practical applications: a **true random number generator** (TRNG). In it cascades of hardware RNG (entropy harvester) are used to periodically reseed a PRNG. When the entropy is sufficient, it behaves as a TRNG.

#### References

[1] Linux manual page on "urandom"

[2] Alzhrani K., Aljaedi A. (2015) "Windows and Linux Random Number Generation Process: A Comparative Analysis", *International Journal of Computer Applications* 113:21

[3] Schiller J., Crocker S. (2005) "IETF RFC 4086 - Randomness Requirements for Security"

[4] Goichon F., Lauradoux C., Salagnac G., Vuillemin T. (2012) "A study of entropy transfers in the Linux Random Number Generator", research report 8060

#### Cite this calculator & page

If you'd like to cite this online calculator resource and information as provided on the page, you can use the following citation:

Georgiev G.Z., *"Random Number Generator"*, [online] Available at: https://www.gigacalculator.com/calculators/random-number-generator.php URL [Accessed Date: 13 Jun, 2021].