Random Number Generator
Generate random whole numbers in any range — one at a time, or a whole set with duplicates ruled out.
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.