Understand your result
Random Number Generator guide
A random number generator looks simple, but the details decide whether the numbers are fair, whether repeats are possible and whether anyone could predict them. This guide explains what the settings mean and how to choose them for common jobs.
Ordinary versus cryptographically secure randomness
Almost all software random numbers are pseudo-random, produced by a formula from an internal state. An ordinary generator such as JavaScript's Math.random aims for speed and an even spread. Its algorithm is not specified for security, so if an attacker could learn its internal state, later values could be predicted.
A cryptographically secure generator, such as the browser's crypto.getRandomValues, is built so that its output cannot be predicted from previous output, and it draws on unpredictable system entropy. It is slightly slower, but fast enough for any use on this page. Choose secure randomness for fair draws, and standard randomness for games and casual picks. For passwords and keys, use a password manager or a vetted cryptographic library.
Repeats, unique numbers and shuffling
With repeats allowed, each draw is independent, like rolling a die many times. The same number can appear more than once, and it does more often than people expect. Ten numbers between 1 and 100 contain a repeat about 37% of the time.
With no duplicates, the tool draws without replacement, like drawing numbered tickets from a hat. This suits raffles, lottery-style picks and selecting a random sample. A shuffle is the special case where you take every number from the minimum to the maximum once, in random order, which is a quick way to randomize a list.
Probability basics for random numbers
For a fair generator over a range of N values, every value has a probability of 1 in N. A roll from 1 to 6 gives each face a 1 in 6 (16.7%) chance, a coin flip from 0 to 1 gives 50% each, and a number from 1 to 100 gives 1% each. The chance of a value not appearing in k independent draws is (1 โ 1/N)^k.
Past results do not change the next draw. A random sequence can include streaks and clusters, and that is normal. Believing that a number is due because it has not appeared is the gambler's fallacy.
Choosing settings for common jobs
To pick winners for a giveaway, number the entries from 1 to N, set the quantity to the number of winners, turn on no duplicates and use the secure source. To roll dice, use 1 to 6 with the quantity set to the number of dice and duplicates allowed. For a coin flip, use 0 and 1.
To create test data, use decimals with the precision you need. To assign an order, shuffle 1 to N. To avoid a number, add it to the exclude list. Remember that the tool cannot improve your odds in games of chance, and that it is not intended for generating passwords or encryption keys.
Continue with a related calculation
- Standard Deviation Calculator
Measure the spread of a set of numbers, including a random sample.
- Percentage Calculator
Work out probabilities and percentages.
- Fraction Calculator
Express a probability as an exact fraction.
- Z-Score Calculator
Compare a value to the mean of a distribution.
References and further reading
- MDN: Crypto.getRandomValues()
The browser's cryptographically strong random number API.
- MDN: Math.random()
Notes that Math.random is not cryptographically secure.
- NIST: Random bit generation
Federal guidance and standards for random number generation.