What it does
The random number generator picks whole numbers at random from the range you set. It can draw one number, or up to 100 different numbers at once, between any two whole numbers from −1,000,000,000 to 1,000,000,000.
The page opens with one number from 1 to 100 already drawn. Change Min, Max or How many and a new draw appears straight away. The numbers are shown in the order they were drawn, not sorted.
How to use it
- Set Min and Max, the lowest and highest number that can come up. Both are included.
- Set How many, from 1 to 100.
- Read the draw under the settings. The line under the count says which range it came from, and “no repeats” when you asked for more than one.
- Select Copy all for every number, one per line, or Copy next to a single number.
- Select Regenerate, or press Ctrl+Enter (⌘+Enter on a Mac), for a new draw with the same settings.
The generator remembers Min, Max and How many on this device, so they’re there the next time you open the page. The numbers themselves are never kept.
How it works
Each number is picked from your browser’s cryptographic random number generator, the same source used for encryption keys. The generator reads the browser’s random bytes 4 at a time, as a 32-bit value from 0 to 4,294,967,295. A plain remainder (modulo) would favour some numbers, because 4,294,967,296 doesn’t divide evenly by most range sizes. So the generator sets aside the few values at the very top that would cause that: for 1 to 100, the last 96 of them. If one of those comes up it’s skipped and the next one is used. What’s left divides evenly, so every number in the range has exactly the same chance.
To make several different numbers, the generator takes them one at a time from the numbers still left in the range, a partial Fisher–Yates shuffle. Each draw is made with the same unbiased step over what’s left, so every possible ordered set of different numbers is equally likely. A range of two billion numbers needs no big list for this: only the numbers already drawn are tracked.
How it’s calculated
A draw of one number from a range of n numbers gives each number 1 chance in n: 1 in 100 for 1 to 100, which is 1%. Several numbers are taken without putting any back, so the first has n choices, the second n − 1, and so on. Three numbers from 1 to 6 can come out in 6 × 5 × 4 = 120 different orders, and each of the 120 has the same chance, 1 in 120.
Every number then has the same chance of being in the draw at all: a given number is among the three in 60 of the 120 orders, which is 50%, or 3 in 6. The first place alone gives each number 1 in 6, about 16.7%.
Worked examples
Three numbers from 1 to 6
Set Min to 1, Max to 6 and How many to 3. If the values drawn are 2, 1 and 0, the draw reads 3, 1, 2, and the line under the count reads From 1 to 6, each equally likely, no repeats. The three are all different, and they stay in the order drawn rather than sorted.
One number from 1 to 100
With the page’s own settings, Min 1, Max 100 and How many 1, a drawn value of 41 gives 42 and a value of 0 gives 1. The line under the count reads From 1 to 100, each equally likely, with no mention of repeats, since there is only one number.
What the odds count
Feeding the draw every possible value for its three places gives 120 draws of 3 numbers from 1 to 6, and all 120 are different. The number 4 is in 60 of them. Over 1 to 100, the 100 values give each number from 1 to 100 once.
Common mistakes
- Leaving out the ends. Min and Max can both come up: 1 to 6 gives a 1 for a drawn value of 0 and a 6 for a drawn value of 5.
- Asking for more numbers than the range holds. 1 to 10 holds 10 numbers, so a How many of 11 is refused at How many, with 10 as the most it can be. The size of a range is Max − Min + 1.
- Waiting for a repeat inside one draw. The numbers of one draw are all different. To allow repeats, draw with How many 1 each time: every draw starts again from the whole range, so a number can come up again in the next one.
Ranges and repeats
The size of a range is Max − Min + 1, and both ends count. 1 to 10 holds 10 numbers, −5 to 5 holds 11, and 7 to 7 holds just the one. How many can be as large as the size and no larger, so −5 to 5 with How many 11 returns every number from −5 to 5 once, in the order drawn.
Negative numbers are copied with an ordinary hyphen-minus, as -5, so they paste into a spreadsheet as they are. The line under the count writes the range with a proper minus sign instead, as From −5 to 5.
Good to know
- Min and Max are included: 1 to 6 can give 1 and can give 6.
- How many can’t be more than Max − Min + 1. Asking for 11 numbers from 1 to 10 shows an error at How many that says how many you can ask for.
- Max has to be at least Min. When they’re equal, the one number in the range comes up.
- Past draws don’t affect the next one. A number that came up a moment ago is just as likely as any other, and a run of similar numbers is a normal result.
- The draws are whole numbers only. For a number with decimals, draw a whole number and divide it.
Privacy
The numbers are drawn in your browser, on your device. Nothing is sent to a server and the numbers aren’t stored. Only your Min, Max and How many are kept, in this browser’s storage, so the page can show them again.