Random Number Generator
Set the lowest and highest numbers, choose how many you want and turn off duplicates if each must be unique, as in a lottery draw, then copy the results. Numbers come from your browser's cryptographic random generator, with rejection sampling so every value is equally likely. Both endpoints can be drawn.
Updated
How to use the Random Number Generator
- 1Set the lowest and highest numbers in your range.
- 2Choose how many numbers you want.
- 3Turn off duplicates if each number must be unique, as for a lottery draw.
- 4Generate, then copy the results.
How it works
Numbers come from crypto.getRandomValues(), the same cryptographic source used for passwords, rather than Math.random(). For a raffle or a decision that matters, that difference is worth having.
Getting a uniform distribution from random bytes takes a little care. Simply taking the remainder of a random number leaves the lower part of the range very slightly more likely — imperceptible for small ranges, but a real bias. Rejection sampling avoids it by discarding values that fall outside a clean multiple of the range.
With duplicates disabled, the tool draws without replacement, which is what a lottery or a prize draw actually does. It also checks that the range is large enough to supply the count you asked for.
Tips and common mistakes
- Turn off duplicates for raffles and draws, so no number can win twice.
- Number your entries before drawing, and publish the range you will use, so the draw is easy to check.
- Record the screen during a public draw if people will want to see that it was fair.
- For shuffling a list of names, Sort Lines can put the lines in a random order.