Random generator

This generates a random value between the supplied values, using Mersenne Twister

from input: 1 999

597

How to pick a random number

  1. Enter the lowest number you want in Start and the highest in End. The page opens with 1 and 999 and a number already drawn.
  2. Press Generate. The result appears in green, under the range it was drawn from.
  3. Press Generate again for another number.

Examples

  • Roll a die: Start 1, End 6.
  • Pick a raffle winner from 250 numbered tickets: Start 1, End 250.
  • Flip a coin: Start 0, End 1, and call 0 heads and 1 tails.
  • A random year in the 1900s: Start 1900, End 1999.

How it works

  • Both ends are included, so 1 to 6 can give 1, 2, 3, 4, 5 or 6, each equally likely.
  • Only whole numbers. Decimals are cut off, so 2.9 counts as 2.
  • Negative numbers work, for example −10 to 10.
  • If Start is bigger than End, the two are swapped for you.
  • Each draw is independent. The same number can come up twice in a row.

Numbers come from PHP's mt_rand(), which uses the Mersenne Twister algorithm. It is fast and evenly spread, which makes it fine for games, draws, sampling and test data.

When not to use it

Mersenne Twister is not cryptographically secure: with enough output, its next numbers can be predicted. Don't use it for passwords, keys, tokens or lotteries with money at stake. For passwords, use the password generator, which uses a secure random source.

FAQ

Can I draw several numbers without repeats? Not in one go. Draw one at a time and skip any number you already have.

Is every number really equally likely? Yes. PHP scales the result to your range without favouring any number, so over many draws each value comes up about equally often.