Random Number and Letter Set Generator

Random Number and Letter Set Generator

Growing AI Skill PRO

Enter Calculation

Formula

Draw=min⁡(Sample Size,N) unique itemswhere{N=|high−low|+1[low,high]=Sample Range\begin{gathered} \text{Draw} = \min\!\left( \text{Sample Size},\ N \right) \text{ unique items} \\[1.5em] \text{where}\quad \left\{ \begin{aligned} N &= |\,\text{high} - \text{low}\,| + 1 \\ [\text{low},\text{high}] &= \text{Sample Range} \end{aligned} \right. \end{gathered}
Usage stats

Advertisement

Results

Answer
22 91 33 40 14
Items generated 5
Population size 100

Report an error on this page

What is the Random Number and Letter Set Generator?

This tool produces a set of one or more randomly chosen items from a range you define. The range can be numeric (such as 1-100) or alphabetic (such as a-j). It is handy for sampling, drawing lots, creating PINs, picking quiz questions, assigning teams, or any task that needs unbiased random selection from a known set.

How to use it

Enter the Sample Size (how many items you want), then the Sample Range in the form START-END. Choose whether to Allow Duplicates (sampling with replacement) and whether to Print Commas between items. Press calculate to get a freshly drawn set in random order.

If both ends of the range are whole numbers it works in numeric mode; if both are single letters it works in letter mode, preserving the case of the first letter.

Flat diagram contrasting sampling with duplicates allowed versus without duplicates
With duplicates the picked item stays in the pool; without duplicates it is removed.

The formula and algorithm

The candidate population is every value in the inclusive range: for numbers, all integers from low to high, giving \(\text{high} - \text{low} + 1\) values; for letters, every character code from the lower to the higher code. Each item is picked uniformly with \(\text{index} = \lfloor \text{random} \times \text{remaining} \rfloor\). Without duplicates the population is shuffled (Fisher-Yates) and the first N items are taken, so every result is distinct. With duplicates each pick is independent and repeats can occur.

$$\text{Draw} = \text{Sample Size} \ \text{items from a population of size } N$$ $$\text{where}\quad \left\{ \begin{aligned} N &= |\,\text{high} - \text{low}\,| + 1 \\ [\text{low},\text{high}] &= \text{Sample Range} \end{aligned} \right.$$

Advertisement

Worked example

Sample Size 5, Range 1-100, duplicates No, commas No. The population is the integers 1 through 100 (\(N = |100 - 1| + 1 = 100\) values). Five distinct uniform draws might give: 48 50 62 18 10. With commas on, the same draw reads 48, 50, 62, 18, 10.

Flat diagram showing random index selection from a pool of items into an output set
Each draw multiplies a random fraction by the remaining count to pick an index from the pool.

Duplicates vs. No Duplicates: Scenario Comparison

The range is inclusive, so the population size is \(N = |\text{high} - \text{low}| + 1\). With duplicates allowed, each draw is independent and there are \(N^k\) ordered results for a sample size of \(k\). Without duplicates, each draw removes one item, so there are \(N\cdot(N-1)\cdots(N-k+1)\) ordered results. Without duplicates, \(k\) cannot be larger than \(N\).

Scenario Range size N Sample size Duplicates setting Possible ordered results Can repeats occur?
4-digit PIN (0-9) 10 4 Allowed 104 = 10,000 Yes, e.g. 7-7-3-7
4-digit PIN (0-9) 10 4 Not allowed 10×9×8×7 = 5,040 No, all digits differ
6 numbers from 1-49 49 6 Not allowed 49×48×47×46×45×44 = 10,068,347,520 ordered (13,983,816 as unordered sets, since 10,068,347,520 ÷ 720) No, all numbers differ
5 letters from a-z 26 5 Allowed 265 = 11,881,376 Yes, e.g. k-e-e-p-k
5 letters from a-z 26 5 Not allowed 26×25×24×23×22 = 7,893,600 No, all letters differ
10 numbers from 1-10 (full shuffle) 10 10 Not allowed 10! = 3,628,800 orderings No, every number appears exactly once

Disallowing duplicates always shrinks the number of possible outcomes. For a 4-digit PIN it removes 4,960 of the 10,000 combinations, which makes the PIN easier to guess. For lots and sampling, distinct draws are usually what you want, because the same item should not be picked twice.

Advertisement

Key Terms and Glossary

Sample size
The number of items the generator draws in one run. Without duplicates it cannot exceed the population size.
Population / range
The full set of values the items are drawn from, for example the integers 1-49 or the letters a-z. Its size is \(N\).
Inclusive range
A range that includes both endpoints. The range 1-10 contains 10 values, because \(N = |10 - 1| + 1 = 10\).
Sampling with replacement (duplicates allowed)
Each drawn item is put back before the next draw, so the same value can appear more than once. The draws are independent, and there are \(N^k\) ordered outcomes.
Sampling without replacement (distinct)
A drawn item is not available again, so every value in the result is unique. The number of ordered outcomes is \(N(N-1)\cdots(N-k+1)\).
Uniform distribution
Every value in the range is equally likely on each draw (with replacement), or every possible subset or ordering is equally likely (without replacement). Over a small number of draws the results can still look streaky or uneven by chance.
Fisher-Yates shuffle
A standard algorithm that produces an unbiased random permutation. It walks through the list and swaps each position with a randomly chosen position not yet fixed. Taking the first \(k\) items of a shuffled list is one common way to draw \(k\) distinct values.
Pseudo-random number generator (PRNG)
An algorithm that produces numbers that look random from an internal state. The numbers are deterministic, so the same starting state gives the same sequence.

Security note: this tool's output should not be treated as cryptographically secure. It is fine for games, lots, classroom sampling, and test data. Do not use it for passwords, encryption keys, security tokens, or PINs that protect anything valuable. Use a cryptographically secure generator, such as your operating system's secure random source or a password manager, for those.

FAQ

What if I ask for more items than the range holds? When duplicates are off, the number of results is limited by the range. Asking for 12 distinct digits from 0-9 returns only 10 items.

Are the results sorted? No. Items appear in the random order they were drawn.

How do I make a 4-digit PIN? Use Sample Size 4, Range 0-9, duplicates No for four distinct digits, or duplicates Yes to allow repeated digits.

Last updated:

Most popular in Math and Statistics

View all Math and Statistics calculators