Random Numbers

Random number generator

Ready
From
To
How many
Seed
Uniform · rejection sampled, no modulo bias

Nothing yet. Results appear here so you can prove what came up.

Advertisement
320 × 100

This generator draws whole numbers from a range you choose, using the browser’s cryptographic randomness with rejection sampling so that every value in the range is equally likely. Turn on "No repeats" to draw a set of distinct numbers — six from forty-nine, for instance — rather than independent draws that may collide.

How to use it

1 Set the range and how many numbers you want.
2 Decide whether repeats are allowed. Lottery-style draws want them off; dice-style draws want them on.
3 Press Generate. Copy all takes the whole list, one per line.

Most naive generators take a random 32-bit value and apply a modulus, which quietly favours the low end of any range that is not a power of two. This one rejects and redraws the small slice of values that would cause the bias, so a range of 1 to 6 is exactly uniform rather than nearly so. The difference is invisible in ten draws and measurable in ten thousand.

Questions

Yes. From 1 to 100 can produce 1 and can produce 100.

MDN — Crypto.getRandomValues()NIST SP 800-90A — recommendation for random number generation
Advertisement
300 × 250
Was this tool any good?
INTERNAL SIGNAL ONLY · WE USE IT TO FIND TOOLS WORTH REBUILDING