The rule
each number is drawn with crypto.getRandomValues, discarding biased draws
Why it works
A computer’s random number is not random in the strict sense, but the system’s cryptographic generator — the same one used to create keys — is indistinguishable from randomness for any practical purpose, and it is what this page uses. The detail almost nobody accounts for is modulo bias: taking the remainder of a large random number by the size of the range favours the lower values whenever the range does not divide the maximum exactly. With six faces and one byte the difference reaches 1.6 per cent, small but real. Here the draws that land in the leftover zone are discarded and redrawn, which is the correct way to avoid it.
How to do it by hand
- Choose the range: the first and last numbers that can come up, both included
- Choose how many you want and whether they can repeat
- Each number is drawn with the system generator
- If a draw lands in the zone that would introduce bias, it is discarded and redrawn
What is worth knowing
Without repeats, the count cannot exceed the size of the range: six numbers from 1 to 49 can be drawn, ten from 1 to 5 cannot, and the page says so rather than hanging. With decimals the no-repeats option disappears, because the chance of two numbers matching to several decimal places is effectively nil and filtering it would only complicate the draw. A warning for prize draws: if the result has to be verifiable by third parties, this is not enough; you need a public, reproducible method with a seed everyone can check afterwards.