Skip to content
Paint Calculator

How Random Number Generators Work

What “random” really means, and how to run a fair draw.

Pseudo-random vs cryptographic randomness

Computers are deterministic, so most “random” numbers come from a formula that produces a sequence that looks random. These are called pseudo-random numbers. They are fine for games and simulations but can be predicted if someone learns the starting value.

Browsers also provide a cryptographically secure source, crypto.getRandomValues, fed with unpredictable data from the operating system. It is designed so the next value cannot be guessed, which makes it the right choice for fair draws and security uses. The Random Number Generator uses it.

Picking a number in a range

To pick a whole number between a minimum and maximum, both included:

number = min + random integer from 0 to (max − min)

A range of 1 to 6 has 6 outcomes, each with probability 1/6. A careless method such as taking a big random number and using the remainder (modulo) can make some outcomes slightly more likely, called modulo bias. A well-built generator rejects the values that would cause it, so every number has exactly the same chance.

Drawing without repeats

When a number must not appear twice, such as lottery-style picks or choosing raffle winners, each pick is made from the numbers that remain. The amount you ask for cannot exceed the size of the range. Choosing 5 different numbers from 1 to 50 can be done in 2,118,760 ways, and each combination is equally likely.

Probability examples

  • Coin flip: 50% heads, 50% tails, every time.
  • Dice: each face of a fair die has a 1 in 6 chance. The chance of at least one six in four rolls is 1 − (5/6)4 = 51.8%.

Myths about randomness

  • “It is due.” After five heads in a row, the next flip is still 50/50. Past results do not change future odds (the gambler’s fallacy).
  • “Random means evenly spread.” Real random sequences include streaks and repeats. A sequence with none is more suspicious, not less.
  • “Random means unpredictable to me.” It means that no one can predict the result. A person asked to pick a “random” number tends to choose 7 or 3 far too often.

Good uses

  • Choosing a winner for an informal giveaway or classroom draw.
  • Board games, role-playing dice and decisions you want to leave to chance.
  • Picking a random sample from a numbered list.

For regulated lotteries, gambling and prize promotions, follow the rules that apply where you live, which may require certified equipment and independent oversight.

Try the Random Number Generator

Pick random numbers between any two values, with or without repeats.

Open the tool