How this tool works
Generates random numbers in any range you specify, one at a time or up to a thousand at once, optionally without duplicates and optionally sorted.
Numbers come from the browser's cryptographic random source rather than from the ordinary pseudo-random function, and rejection sampling is used to draw them into range. That second part matters more than it sounds: taking a random number modulo a range makes the lowest values slightly more likely whenever the range does not divide evenly, and rejection sampling avoids that bias by discarding draws that fall in the uneven remainder. The result is a uniform distribution rather than an almost-uniform one, which is what makes the output fit for a draw or a ballot.
What makes a draw fair
- Modulo bias is subtle and real: the naive approach skews towards lower numbers. Rejection sampling costs a few discarded draws and removes the skew entirely.
- Without duplicates the range must be large enough: asking for fifty unique numbers from a range of twenty has no answer, and the tool says so rather than looping forever.
- Sorting is display only: the numbers are drawn first and ordered afterwards, so sorting does not affect which came out.
- Random does not mean evenly spread: genuine randomness produces clusters and gaps. A result that looks patternless to the eye has usually been tidied up.