How Random Number Generators Work and Why Fair Picks Matter
Developer · Published October 17, 2026 · Updated October 24, 2026 · 3 min read
Written by Akinrinmade Michael
Computers are predictable machines, so getting random numbers from one takes some care. For a game night it hardly matters, but for a prize draw or a password, how the numbers are made does. Here's what's going on behind the buttons, and how to run a pick people will trust.
Two kinds of randomness
Most programming languages have a simple generator that produces numbers that look random but follow a formula, so someone who knows its state can predict what comes next. Browsers also provide a secure generator, fed by unpredictable events in the device, which is built for things like encryption keys. The tools on this site use the secure one, so nobody can guess the next result. The simple kind is fine for shuffling a playlist and wrong for anything with a prize or a secret.
A bias that is easy to introduce
A common shortcut maps a big random number onto a small range using the remainder. If the big range doesn't divide evenly, some results come up slightly more often. Here's a concrete case. Suppose a random byte, a number from 0 to 255, is turned into a number from 0 to 99 by taking the remainder after dividing by 100. There are 256 possible bytes, and 256 is 2 hundreds and 56 left over. So the results 0 to 55 can each come from three bytes, and the results 56 to 99 can come from only two. The low numbers are 50 percent more likely.
A careful generator throws away the few values that would cause the lopsidedness and draws again. The Random Number Generator does this, so every number in your range has an equal chance.
Picking without repeats
To draw several different numbers or names, like pulling tickets from a hat, shuffle the whole list and take from the top. Picking again and again at random would sometimes repeat. The standard method is the Fisher-Yates shuffle: walk down the list, swap each item with a randomly chosen item from the part not yet fixed, and every ordering is equally likely. The Random Name Picker uses a fair shuffle to choose a winner or to split people into teams.
A tempting shortcut is to sort the list with a random yes-or-no comparison. It looks fine and it isn't fair, because sorting algorithms don't expect inconsistent answers, and some orderings come up more than others. Use a proper shuffle.
What dice and coins really do
- A fair coin lands on each side half the time, and a streak of heads doesn't make tails more likely next.
- A single six-sided die gives each number an equal chance.
- Two dice added together aren't equal: 7 is the most likely total, with 6 of the 36 combinations, while 2 and 12 have just one each.
- The Dice Roller lets you try these ideas, roll game dice and keep a history.
People often see patterns in random results. Three sixes in a row feels suspicious, and it happens about once in every 216 rolls of three dice, so across a long game it's bound to happen. Short runs of luck are normal and aren't a sign something is broken.
Running a fair draw
- Fix the rules and the closing time in advance, and share them.
- Number every eligible entry once, and keep the list.
- Draw in view of the group, or on a recording.
- Draw once. If the result is unwelcome, that's not a reason to draw again.
- Share the list, the number drawn and a screenshot of the result.
Random IDs
A random identifier is only useful if two never match. A version 4 UUID has 122 random bits, so a clash is astronomically unlikely, and the UUID Generator makes them with the secure generator too. The guide to UUID, ULID and NanoID compares the options.
When you want the same numbers twice
Sometimes repeatability is the point. Tests and simulations use a seeded generator: give it the same starting number and it produces the same sequence every time. That's useful for debugging and for sharing a result, and it's the opposite of what you want for a draw or a password. The tools here don't use seeds, so every draw is new.