Random Number Generator: How the Draw Works and When to Trust It
By FindMySum · Last reviewed
A random number generator picks whole numbers from a range so that every value has the same chance of coming up. This one draws up to 10,000 numbers between −1,000,000 and 1,000,000, with or without repeats, and every draw is reproducible from a seed stored in the page link. That combination matters: the numbers are unpredictable before you press Generate, but once drawn they can be checked by anyone you share them with. This article explains how the draw is made, which figures in the result are fixed by your settings, what the probabilities look like, and where the method stops being good enough.
How a draw is made
Step 1: a seed from a secure source
When you press Generate, the page asks your browser for a 32-bit number from crypto.getRandomValues, the Web Crypto function that draws on the operating system's cryptographically secure generator. That generator is seeded from physical sources of unpredictability inside the device, the same kind of entropy NIST's random bit generation standards are built around. The result, a whole number from 1 to 4,294,967,295, becomes the seed and is written into the URL as the draw number.
Step 2: expanding the seed
A small, well-tested pseudo-random algorithm called mulberry32 turns the seed into a stream of 32-bit values. Each value looks random and passes common statistical tests, but the stream is fixed by the seed. That is the point: the same seed and the same settings always give the same numbers, so a link shows the same draw on every device.
Step 3: fitting values into your range
Each 32-bit value r becomes a number in your range by
number = min + (r mod range size), where range size = max − min + 1.
A plain remainder would be slightly unfair. There are 4,294,967,296 possible values of r, and that total is rarely an exact multiple of the range size, so a few results would get one extra way to occur. For a range of 100, the leftover is 96 values, so the generator discards any r at or above 4,294,967,200 and draws again. That happens about twice in every 100 million draws, and it makes all 100 outcomes exactly equally likely. For the widest range allowed, 2,000,001 values, a plain remainder would make some numbers about 0.05% more likely than others; rejection removes that too.
Step 4: unique numbers
With duplicates off, the generator runs the first steps of a Fisher–Yates shuffle: for each pick it chooses a random position among the values not yet used and swaps it to the front, like drawing cards from a deck without putting them back. Only the swapped positions are stored, so even a two-million-value range needs no large list. Sorting, if you ask for it, happens after the draw and changes only the order shown.
Worked example: the calculator's defaults
The generator opens with a minimum of 1, a maximum of 100, 10 numbers, duplicates allowed, no sorting and seed 1.
- Range size = 100 − 1 + 1 = 100 possible values.
- Each number is drawn independently, so each has a 1 in 100 chance of being any particular value, on every draw.
- Seed 1 always produces the same ten numbers: 68, 34, 88, 22, 4, 53, 65, 21, 85, 18.
Those ten values are not special; they are simply what seed 1 gives with these settings, and pressing Generate replaces the seed with a fresh one. The deterministic parts of the result are the range size and the probabilities. Any one draw is only one sample.
A lottery-style draw
Change the settings to 6 numbers from 1 to 49, duplicates off and sorted, and keep seed 1. The generator returns 11, 14, 32, 38, 41, 49. With 49 values and 6 picks, there are 13,983,816 possible combinations, so any particular set, including this one, had a 1 in 13,983,816 chance. A set like 1, 2, 3, 4, 5, 6 is exactly as likely; it only looks less random.
Reading the result sensibly
Streaks and clusters are normal. Truly random sequences contain runs and gaps that look patterned. In ten draws from 1 to 100 there is about a 37% chance of at least one repeat, and about a 10% chance that any particular number you have in mind shows up at least once. People asked to invent random numbers tend to avoid repeats and spread values too evenly, which is one way faked data gets caught.
Small samples don't look uniform. Ten draws will not cover the range evenly. Generate a few hundred and the counts in each band of ten will even out, though never perfectly. The average calculator and standard deviation calculator are useful for checking: for a large uniform draw from 1 to 100 the mean should settle near 50.5.
Without replacement changes the odds as you go. With duplicates off, each pick removes a value, so later picks come from fewer options. Every set of numbers is still equally likely, which is what makes it suitable for choosing winners or a random sample.
When not to use it
This tool is built for games, classroom picks, simulations, random sampling and informal prize draws. It is not suitable for passwords, encryption keys or anything security-related, because the seed travels in the link and anyone who has it can reproduce the numbers. A 32-bit seed also limits a draw to about 4.3 billion possible starting points, far fewer than a security application needs. For those uses, the NIST SP 800-90 series describes the kind of generator required, and your operating system or a password manager provides one. Lotteries and contests regulated by law, such as those overseen by provincial lottery corporations, use certified equipment and audited procedures that a web page can't replace.
Using the result
For a survey or study sample, number your population list and draw without duplicates; the percentage calculator can then show what share of the population you sampled. To simulate dice, use 1 to 6 with duplicates on; for a coin, use 0 to 1. Whatever you draw, keep the link: it is the record that the draw happened the way you say it did.
More questions
What are the chances that a draw of 10 numbers from 1 to 100 contains a repeat?
About 37%, which surprises most people. The first number can be anything, the second must avoid one value, the third two values, and so on, so the chance of no repeat is 1 × 0.99 × 0.98 × … × 0.91, about 0.628. This is the birthday problem in miniature. If repeats would spoil your use, turn duplicates off rather than hoping they won't happen.
How do I run a fair prize draw with it?
Number the entries 1 to N in a list everyone can see, set the range to 1 to N, choose how many winners, and turn duplicates off so no one wins twice. Announce the settings before you press Generate, press it once, and share the resulting link: anyone who opens it sees the same draw, which shows it wasn't rerun until a favoured entry came up. Contests regulated by law may need a certified process instead.
What is modulo bias?
It is a small unfairness that appears when a random 32-bit value is reduced to a range by taking a remainder. Because 2^32 is not usually a multiple of the range size, some results get one extra way to occur. The generator avoids this by discarding the few raw values at the very top of the 32-bit range and drawing again, so every number in your range has exactly the same chance.
Can I generate decimal numbers or a weighted draw?
Not directly; the generator draws whole numbers with equal chances. For decimals, scale up and divide afterwards: draw from 0 to 1,000 and divide each result by 1,000 for three decimal places between 0 and 1. For a weighted draw, give heavier options more numbers, for example 1 to 3 for option A and 4 for option B to make A three times as likely.
What is the difference between pseudo-random and truly random numbers?
A pseudo-random generator is an algorithm: from a starting value it produces numbers that pass statistical tests for randomness but are completely determined by that start. A true random source measures a physical process such as electronic noise. This page combines the two: the browser's secure generator, which gathers physical randomness, picks the seed, and a fast algorithm expands it.
If I keep the seed but change the range, do I get related numbers?
The underlying 32-bit values stay the same, but each one is mapped into the new range by a remainder, so the numbers you see change in ways that are not easy to predict by eye. Changing the count keeps the start of the draw: with duplicates allowed, raising the count from 10 to 12 keeps the first 10 numbers and adds two more.
Sources
- Random Bit Generation project, NIST Computer Security Resource Center
- SP 800-90A Rev. 1: Recommendation for Random Number Generation Using Deterministic Random Bit Generators, NIST
- Crypto: getRandomValues() method, MDN Web Docs
- Introductory Statistics 2e, chapter 1 (sampling) and chapter 3 (probability), OpenStax (Rice University)
This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.