Statistics
Random number generator
Pick random numbers between any two values. Set the range and how many you want, choose whether repeats are allowed, and press Generate.
Show the working, step by step
How the numbers are drawn
For whole numbers from a to b, there are b − a + 1 possible values, and each draw picks one with equal probability:
P(any one value) = 1 ÷ (b − a + 1) value = a + ⌊u × (b − a + 1)⌋, u uniform on [0, 1)
Decimals work the same way on a finer grid. With d decimal places the step is 10⁻ᵈ, and the
generator picks a random whole number of steps above the lowest value. Because every value on the grid
is equally likely, the ends of the range are as likely as the middle. The random u comes from 53 bits of
crypto.getRandomValues, so even very wide ranges show no bias toward particular values.
A worked example
The default draws 10 whole numbers from 1 to 100 with repeats allowed. There are 100 possible values, so each draw has a 1 in 100 chance of any given number. The results will look lumpy: a few close together, some gaps. That is normal.
With repeats allowed, how likely is at least one repeated number among the 10? It is the birthday problem with 100 “days”:
P(repeat) = 1 − (100 × 99 × … × 91) ÷ 100¹⁰ = 0.372
So more than a third of the time a list of 10 contains a duplicate. If that is not what you want, choose “No repeats”, which draws the way you would pull numbered tickets out of a hat.
The mean of the 10 numbers is shown against the expected mean, (1 + 100) ÷ 2 = 50.5. The standard deviation of one draw is √((100² − 1) ÷ 12) = 28.9, so the mean of 10 draws typically lands within 28.9 ÷ √10 = 9.1 of 50.5.
Using the numbers
For a random sample from a numbered list, number the items 1 to N, draw without repeats, and take those items. For random assignment to two groups, draw N unique numbers from 1 to N; the first half go to group A. Sorting the output makes it easier to check against a list, and does not change which numbers were drawn.
Repeats or no repeats?
Allowing repeats models independent draws with replacement, like rolling a die or spinning a wheel several times. Forbidding repeats models draws without replacement, like dealing cards or picking raffle tickets. The choice matters for statistics: a simple random sample from a population is drawn without replacement, while a bootstrap resample is drawn with it.
Common mistakes
- Asking for more unique numbers than the range holds. Ten unique whole numbers from 1 to 5 is impossible, and the generator will say so.
- Reading patterns into a short list. Clusters and gaps are what randomness looks like.
- Rounding random decimals yourself. That can make the end values half as likely as the others; set the decimal places here instead.
Common questions
How do I pick a random number between 1 and 10?
Set the lowest number to 1, the highest to 10 and how many to 1, then press Generate. Both ends are included, so 1 and 10 are as likely as any number in between: 1 in 10 each.
How do I draw lottery numbers or raffle winners without repeats?
Choose “No repeats (unique)”. For 6 numbers from 1 to 49, set the range to 1–49, how many to 6 and order to smallest first. Every set of 6 is equally likely, just as if you drew balls from a drum without putting them back.
Are the numbers truly random?
They come from the browser's cryptographically secure generator, which is seeded from unpredictable hardware and system events. That is suitable for games, draws, sampling and classroom work. For a regulated lottery or legal draw you will usually need an audited process as well as good random numbers.
Can it make random decimals?
Yes. Choose “Decimals” and set the number of decimal places, up to 6. With 2 decimal places between 0 and 1, there are 101 possible values (0.00, 0.01, …, 1.00), each equally likely.
Why does the mean of my numbers differ from the expected mean?
Random samples vary. For 10 whole numbers from 1 to 100, the expected mean is 50.5, but the standard deviation of the sample mean is about 9.1, so a mean anywhere from roughly 32 to 69 is ordinary. Generate 10,000 numbers and the mean will be much closer to 50.5.
Related calculators
-
Dice roller
Random rolls of any dice with a modifier.
-
Coin flipper
Flip one coin or thousands at once.
-
Sample size calculator
How many people to sample before you draw them.