Random number generator
Pick a random number between any two numbers, or generate a whole list.
How to use the random number generator
- Enter the lowest and highest numbers you want (both are included).
- Choose how many numbers to generate, up to 10,000, and whether repeats are allowed.
- Tick Sort if you want the list in order from smallest to largest.
- Tap Generate or press the space bar. Copy puts the whole result on your clipboard, separated by commas.
How the numbers are chosen
flipj uses your browser's built-in cryptographic random number generator (crypto.getRandomValues), the same source browsers use for encryption keys. We also avoid "modulo bias", a subtle flaw where some results come up slightly more often than others. Every result is generated on your device, so nothing you enter is sent to us.
With "Allow repeats" turned off, flipj needs every number in the result to be different. For ranges of up to 100,000 numbers it shuffles the whole range with the Fisher–Yates method and takes the first numbers from the top, just like drawing numbered balls from a bag. For bigger ranges it draws numbers one at a time and throws away any it already has. Both ways give every possible set of numbers the same chance.
The range can run from about minus 9,007,199,254,740,991 to plus the same, the largest whole numbers a browser can handle exactly. If you type the minimum and maximum the wrong way round, flipj swaps them for you. On screen a long list shows its first 2,000 numbers; Copy always gets all of them.
Repeats come sooner than you think
With repeats allowed, each pick is independent, so the same number can turn up twice in a row. People are often surprised by how quickly that happens. It is the same maths as the famous "birthday problem": in a room of 23 people, two probably share a birthday.
| Range | A repeat is more likely than not by pick number | Chance of at least one repeat in 10 picks |
|---|---|---|
| 1 to 10 | 5 | >99.9% |
| 1 to 20 | 6 | 93.5% |
| 1 to 50 | 9 | 61.8% |
| 1 to 100 | 13 | 37.2% |
| 1 to 365 | 23 | 11.7% |
| 1 to 1,000 | 38 | 4.4% |
So if you are numbering raffle tickets or choosing several people, untick "Allow repeats". If you are simulating something that really can repeat, such as dice rolls or customers arriving, leave it ticked.
Picking a random sample from a list
A random number generator is the simplest honest way to choose rows for a survey, a spot check or an audit:
- Number the rows of your spreadsheet from 1 to the last row (most spreadsheets have a row number column already).
- Set the minimum to 1, the maximum to the number of rows, and How many to your sample size.
- Untick Allow repeats so no row is chosen twice, and tick Sort so the rows are easy to find.
- Copy the list and paste it into your notes, so you have a record of exactly which rows were picked.
For example, to check 20 of 850 invoices, generate 20 numbers from 1 to 850. Every invoice has the same 2.4% chance of being checked, and nobody can say the easy ones were chosen on purpose.
What a random list looks like
Truly random numbers are lumpier than most people expect. Draw 10 numbers from 1 to 10 with repeats allowed and on average you will see only 6.5 different numbers; the rest are repeats, and a few numbers will not appear at all. Draw them without repeats and you get all ten, in a shuffled order. Neither result means anything is wrong. If you need every number exactly once, that is a shuffle, not a series of independent picks, and the "no repeats" setting is the one to use.
Uses
- Giveaways and raffles: number your entries, then pick the winner. For a draw strangers have to trust, use the fair giveaway picker, which leaves a public record.
- Classrooms: pick a student by register number, a page of the textbook or a question from a numbered worksheet.
- Games: "guess the number", choosing who goes first, or random events in a game you are designing.
- Sampling: choose random rows from a list for a survey or audit, as described above.
- Fixed ranges: there are shortcut pages for 1 to 10 and 1 to 100, and a lottery number generator for lucky dips.
Questions
Are the minimum and maximum included?
Yes. A range of 1 to 10 can produce both 1 and 10.
Can I generate numbers without repeats?
Yes. Turn off "Allow repeats" and each number appears at most once, as long as the range is big enough. Ask for more numbers than the range holds and flipj tells you.
How many numbers can I generate at once?
Up to 10,000. The screen shows the first 2,000 and the Copy button copies them all.
Can I use negative numbers or big numbers?
Yes, any whole numbers from about minus 9 quadrillion to plus 9 quadrillion.
Can it generate decimals?
No, it produces whole numbers only. For two decimal places, generate in a range 100 times bigger and divide by 100: 0 to 500 gives 0.00 to 5.00.