Random Number Generator
Cryptographically random, and genuinely unbiased.
Everything is processed in this tab. Nothing you paste is sent anywhere.
Every tool runs entirely in your browser. Your files are never uploaded to a server.
True randomness needs an unpredictable source and an unbiased selection method. This uses the browser's cryptographic generator with rejection sampling, so every number in the range is equally likely.
How to use Random Number Generator
- Set the range. Any lowest and highest values, negatives included.
- Choose how many. Turn on no repeats for a draw or a lottery.
- Or paste a list. With options in the box, it picks between them instead.
About generating random numbers
Generating a random number well involves two separate problems, and most tools only solve the first. The source has to be unpredictable, which rules out the ordinary random function built into most languages — those are deterministic algorithms seeded from something like the clock, and given a few outputs their entire future sequence can be reconstructed. The browser's cryptographic generator draws from the operating system's entropy pool instead, which is the same source used to produce encryption keys. The second problem is selection, and it is the one that gets skipped. Converting a random 32-bit value into a number between one and one hundred by taking the remainder introduces a bias, because 2^32 is not a multiple of 100. The leftover values at the top of the range wrap around onto the lowest results, making the first few outcomes marginally more likely than the rest. The effect is tiny — around one part in forty million here — and it is still a defect, because a generator with a known bias is not a fair one. Rejection sampling fixes it by discarding values in that leftover region and drawing again, at the cost of an occasional extra draw. Unique draws add a third consideration. The naive approach builds the whole range as an array and shuffles it, which is fine for a hundred entries and impossible for a million. A partial Fisher-Yates over a sparse map produces the same result while touching only the positions actually drawn.
Frequently asked questions
Is this actually random?
What is wrong with using modulo?
How does no-repeats work for a huge range?
Can I use this for a prize draw?
Is the result sent anywhere?
Last updated