➗ Math & Statistics Calculators › Statistics & Probability

Random Number Generator (Range, Unique, Sorted)

Generate secure random numbers in any range with count, unique-draw, and sort options, plus generation history and the odds behind every draw.

Random Numbers — interactive calculator, computed instantly in your browser.

📚 Authoritative Educational Guide

How Random Number Generators Actually Make Their Picks

A random number generator picks integers where every value in the range is equally likely — a uniform distribution. It sounds trivial until you try to build one: naïve code is predictable, biased, or both. This generator offers count control, unique (without-replacement) draws, sorting, and history, backed by your browser's cryptographic randomness whenever it is available.

1. Crypto Randomness vs Math.random()

randInt = min + (value mod range), with rejection sampling to stay uniform
  • Math.random() is a seeded PRNG — fast, fine for games, but predictable to anyone who observes enough outputs
  • crypto.getRandomValues() pulls from the operating system's entropy pool — suitable for secrets, tickets, and audited picks
  • Modulo bias:232 is not divisible by most ranges; raw modulo over-favors low values. We compute the largest exact multiple of the range and reject the rare out-of-band sample, looping until it passes
  • Huge ranges (beyond232) skip rejection sampling and fall back to floating-point scaling, where uniformity is limited only by double precision

2. Unique Draws, Sorting, and Collisions

Unique mode samples without replacement — a Set collects values until the count is reached, so "no repeats" is guaranteed (and impossible when the count exceeds the range:5 numbers from1–4 has no solution). Sorting reorders the batch for readability and changes nothing about the odds. The flip side is famous: even with repeats allowed, the birthday paradox means23 random people share a birth date with ~50% probability in a365-day range — collisions arrive far faster than intuition expects.

3. Odds Behind Each Draw

  • One specific number in1–100: 1 in100 per draw — and1 in100 every single draw; previous results never "warm up" the generator
  • An exact batch of5 repeats:1005 = 1 in1010 — the calculator prints this whenever it is computable
  • Picking k numbers from n: that is an nCr problem — a5-from-69 lottery has20,259,280 distinct tickets, which the combination calculator will show you
  • Legitimate uses: raffles, sampling frames, game mechanics, Monte-Carlo simulations, and splitting groups — anywhere a verifiable fair pick matters

🔗 Chance & Counting Cross-References

Random draws are uniform probability in action — connect them to the odds math in our 🧮 Math Hub for probability, combinations, and statistics solvers.

Picking k numbers from a range is literally an nCr problem: the combination calculator shows how many possible tickets exist.

Frequently Asked Questions (Random Numbers)

Are the generated numbers truly random?

In modern browsers the generator uses crypto.getRandomValues(), which draws from the operating system's entropy pool — the same class of randomness security software depends on. Where unavailable it falls back to Math.random(), a high-quality but deterministic PRNG.

Why can't I generate more unique numbers than the range contains?

Unique mode draws without replacement, so the count cannot exceed the range size: from1–10 you can request at most10 unique numbers. The calculator blocks the impossible request instead of silently repeating values.

Does sorting or regenerating affect the odds?

No. Sorting only rearranges a completed batch, and every fresh generation starts from the same uniform distribution — a number that appeared last draw is exactly as likely this time. Independence between draws is the defining property of a proper generator.

What should I use for a raffle or giveaway?

Enter the number of entrants as both minimum and maximum, choose the number of winners, and enable unique draws so nobody wins twice. For high-stakes or public draws, generate with unique mode on and screenshot the batch — the underlying randomness is audit-grade.