StatGardenREF. DESK
Calculators/Maths/Random number generator
Maths

Random number generator calculator

Draws numbers from a range: press recalculate for a new set.

What this calculator does

A random number generator draws values from a range with each outcome equally likely. The distinction that matters most is whether repeats are allowed: drawing without replacement, as a lottery does, is a different process from drawing with replacement, as a dice roll does.

Every value here is regenerated each time the calculator runs, so pressing reset or changing any input produces a fresh draw. The numbers in the worked examples below were generated when the page was built and will not match what you see in the tool: that is the nature of randomness rather than an error.

The formula

Formulax = min + ⌊random × (max − min + 1)⌋ for integers

Unique draws use a pool that shrinks as values are taken, which guarantees no repeats. Draws with replacement scale a random fraction across the range independently each time. Both use the browser’s built-in generator, which is pseudorandom: deterministic given its internal state, but statistically indistinguishable from random for ordinary purposes.

TermMeaning
Without replacementEach value can appear at most once.
With replacementValues may repeat.
PseudorandomGenerated by an algorithm, not a physical process.
UniformEvery value in the range equally likely.

The inputs explained

FieldWhat to enter
MinimumThe lowest value that can be drawn, inclusive.
MaximumThe highest value, inclusive.
How manyHow many numbers to draw. For unique draws this cannot exceed the size of the range.
Allow repeatsWhether repeats are allowed. Choose unique for lottery-style draws, repeats for dice-style rolls.

When to use it

Drawing lottery-style numbers

Set the range and count to match the game and choose unique. Six from 45 is the common format, and every combination is equally likely.

Picking a winner fairly

Number your entrants and draw one. It is more defensible than choosing by eye, and demonstrably unbiased.

Sampling from a list

Selecting a random subset for quality checks or a survey. Unique draws prevent the same item being picked twice.

Simulating dice or coins

Allow repeats and set the range to match: 1 to 6 for a die, 1 to 2 for a coin. Repeats are essential here, since real dice have no memory.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

Sample draws from different ranges

Six unique numbers drawn from a range of upper limits. These particular values were generated when this page was built.

Six unique numbers
RangeNumbersSortedSum · average
1 to 101, 4, 10, 9, 5, 81, 4, 5, 8, 9, 1037 · 6.17
1 to 2013, 1, 8, 15, 17, 141, 8, 13, 14, 15, 1768 · 11.33
1 to 4516, 6, 45, 42, 5, 33, 5, 6, 16, 42, 45117 · 19.50
1 to 5016, 34, 47, 28, 1, 241, 16, 24, 28, 34, 47150 · 25.00
1 to 10022, 32, 76, 85, 14, 44, 14, 22, 32, 76, 85233 · 38.83
1 to 1000158, 792, 119, 992, 671, 8787, 119, 158, 671, 792, 9922,819 · 469.83
The average of a uniform draw tends toward the midpoint of the range as the count grows, but with only six numbers the variation from that midpoint is still substantial.

How many numbers you draw

Drawing increasing quantities from 1 to 100.

1 to 100, unique
CountNumbersSum · average
1 numbers2929 · 29.00
3 numbers31, 83, 28142 · 47.33
5 numbers18, 7, 81, 60, 36202 · 40.40
8 numbers56, 36, 1, 73, 42, 79, 98, 97482 · 60.25
12 numbers35, 6, 72, 9, 80, 89, 18, 16, 50, 48, 84, 14521 · 43.42
With more draws the average settles closer to 50.5, the midpoint of 1 to 100. This convergence is the law of large numbers in miniature.

Questions

Are these numbers truly random?

They are pseudorandom, generated by an algorithm from an internal seed. For games, sampling and everyday use this is entirely adequate. For cryptography or anything where an adversary might predict the output, a cryptographically secure generator is required.

Why do I get different numbers each time?

Because a new draw is made whenever the calculator runs. Changing any input or pressing reset triggers a fresh set: there is no fixed seed.

What is the difference between unique and repeating draws?

Unique draws remove each value from the pool once taken, like drawing balls from a bag. Repeating draws replace it, like rolling a die. Lottery numbers are unique; dice rolls are not.

Can I draw more numbers than the range allows?

Not with unique selected: there are not enough distinct values. The calculator falls back to allowing repeats in that case.

Is one set of lottery numbers more likely than another?

No. Every combination has exactly the same probability, including 1-2-3-4-5-6. Sequences that look patterned feel less likely but are not, which is one of the most robust findings in the psychology of probability.

For the odds of a given draw, see permutations and combinations or the probability calculator.