To generate k distinct numbers from 1 through n fairly, every permitted k-number set should have probability 1/C(n,k). Enforcing distinctness is necessary, but it is not sufficient: a method can avoid duplicates while still favouring some sets.
Two standard constructions are easy to reason about: sample uniformly and reject duplicates, or partially shuffle the pool. Both need an unbiased way to choose a bounded integer.
Method one: reject labels already selected Start with an empty set. Propose a uniform integer from 1–n. Add it if it is new; otherwise draw again. Stop when the set contains k labels. At each stage, all remaining labels are treated symmetrically, so every ordered selection of k distinct labels has equal probability.
Each unordered set has k! possible orders. Since this number of orders is the same for every set, forgetting the order preserves uniformity across sets. Sorting the final numbers is therefore a presentation choice, not a probability change.
Method two: shuffle only what you need Create the list 1, 2, …, n. At position i, choose a uniform position from i through n−1, swap it into position i, and continue until k positions have been selected. The first k entries form the selected sample.
It is important that the remaining interval includes all eligible positions with equal probability. Choosing from the wrong bounds, repeatedly sorting with a random comparator, or applying a biased bounded-integer conversion can break the argument.
A tiny check catches a large class of mistakes Select two numbers from four. The six possible sets are {1,2}, {1,3}, {1,4}, {2,3}, {2,4}, {3,4}. A correct unrestricted method assigns each probability 1/6. Now consider an implementation that chooses a random starting label and always pairs it with the next label around a circle. It has no duplicates, yet it never produces {1,3} or {2,4}. Distinct does not mean uniform.
This small-space reasoning is often more revealing than generating a million outputs and checking whether individual labels have similar frequencies. The flawed circular method can make each individual label equally frequent while missing whole combinations.
Keep number pools separate If a game draws main numbers from one pool and a special ball from another, distinctness normally applies separately within each pool. The same numeral can appear in both pools. Removing a main number from the special pool because its label matches silently changes the game's outcome space.
Similarly, a digit game that allows repeated digits should not use a no-repetition method at all. “Random numbers” is not a complete specification; the valid outcomes must come first.
Filters are additional conditions Rejecting lines with consecutive numbers, repeated final digits or an unusual sum narrows the output space. It may match a user's aesthetic preference, but it does not make the surviving line more likely to win a uniform draw. A generator should make such conditions explicit.
Use the combinations calculator to see the size of a game's outcome space. Then use the relevant game generator when you want an impartial selection that follows those rules. Correct generation makes every permitted choice available; it does not turn a choice into a prediction.
Leave the selection to chance
If you want a valid random game line, open the relevant generator. A generated line is not an official entry or a prediction, and it does not improve the probability of a specified valid combination.
Sources and further reading
The worked examples and derivations are RoomForChance explanations. Operator sources establish game parameters; research sources support the specific points identified above. University links are references, not endorsements.
- Joe Blitzstein and Jessica Hwang · Harvard Stat 110 / Introduction to ProbabilityUniversity-level further reading on counting, conditioning and probability models.
Continue the argument
How Many Lottery Combinations Are There? The C(n,k) Formula
Derive the lottery combination formula, work through C(49,6), and learn when separate pools or ordered digits require a different count.
With vs Without Replacement: The Probability Difference
Understand how replacing a drawn item changes independence, duplicate possibilities and the formulas used for lottery and digit games.
Rejection Sampling: How Discarding Values Can Preserve Fairness
A practical derivation of rejection sampling for integer ranges and distinct lottery numbers, with efficiency and failure cases explained.