Orpheus

Random Number Generator

Cryptographically random, and genuinely unbiased.

Options
No repeats
Result

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

  1. Set the range. Any lowest and highest values, negatives included.
  2. Choose how many. Turn on no repeats for a draw or a lottery.
  3. 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?
It uses crypto.getRandomValues, which draws from the operating system's entropy pool — the same source used for cryptographic keys. That is not the mathematically pure randomness of a physical process, but it is unpredictable in every practical sense.
What is wrong with using modulo?
Taking a random 32-bit value modulo a range is biased unless the range divides evenly into 2^32. The leftover values at the top wrap onto the first few results, making them very slightly more likely. Rejection sampling discards those values instead, which removes the bias entirely.
How does no-repeats work for a huge range?
By a partial Fisher-Yates shuffle over a sparse map rather than building the whole range in memory. Drawing six unique numbers from one to a million costs the same as drawing six from one to ten, and uses no more memory.
Can I use this for a prize draw?
The selection is fair, which is the part that matters mathematically. For anything with a legal dimension you also need an auditable record of who entered and what was drawn, and that is a process question rather than a randomness one.
Is the result sent anywhere?
No. Generation happens entirely in your browser, and nothing about the range, the count or the results leaves your device.

Last updated