Random Number Generator
Generate unbiased random numbers within any range. Features Web Crypto CSPRNG hardware entropy, duplicates toggle, bulk batches up to 10,000, sorting, delimiter choices, and CSV export.
All formulas and computation matrices for this calculator execute directly in your browser with zero latency. Enter your parameters to see instant results.
Who Uses This Calculation & Why Accuracy Matters
Software developers, statisticians, research scientists, raffle organizers, and board game enthusiasts use this Random Number Generator (RNG) to produce cryptographically strong or pseudo-random integers and decimal floating-point values across custom ranges with or without replacement.
A medical researcher randomly allocating 100 clinical trial participants into Control (0) vs. Treatment (1) cohorts without bias.
A charity selecting 3 winning ticket numbers from 1,500 sold raffle tickets (numbered 1 to 1500) without replacement.
Simulating the roll of a 20-sided die (D20) for critical check rolls in tabletop gaming.
Random Number Generation Algorithms & Statistical Randomness Benchmarks
Comparison of pseudo-random, cryptographic, and true physical hardware random number generators.
| Generator Architecture | Primary Underlying Algorithm | Period Length | Cryptographic Security | Primary Application |
|---|---|---|---|---|
| PRNG (General) | Mersenne Twister (MT19937) | 2¹⁹⁹³⁷ - 1 (~4.3 × 10⁶⁰⁰¹) | Insecure (Predictable from state) | Monte Carlo simulations, video games, modeling |
| CSPRNG (Cryptographic) | AES-CTR / ChaCha20 / /dev/urandom | Effectively Infinite | Cryptographically Secure | Cryptographic key generation, password salts, security tokens |
| TRNG (Physical Hardware) | Thermal noise, radioactive decay, quantum photonic jitter | Infinite (True entropy) | Highest Theoretical Security | Military cryptography, high-stakes lottery machines |
| Linear Congruential (LCG) | X_{n+1} = (aX_n + c) mod m | Short (typically 2³² or 2⁴⁸) | Insecure (Obvious lattice planes) | Historical; embedded microcontrollers with minimal RAM |
* NIST SP 800-22: A Statistical Test Suite for Random and Pseudorandom Number Generators.
Discrete Uniform Distribution & Cryptographic Scaling Equations
Converts a normalized uniform random floating point variable U ∈ [0, 1) into a discrete integer in the closed interval [min, max].
Cryptographically generated random decimal in [0, 1).
Minimum allowable generated number in range.
Maximum allowable generated number in range.
Rounds down to nearest integer.
Step-by-Step Worked Examples with Real Numbers
Worked Example 1: Scaling a Random Value to [1, 100]
100 possible discrete integers.
Continuous scaled value.
Generated random integer is 75.
Worked Example 2: Rolling a Standard 6-Sided Die
Generated roll is 1.
Assumptions, Edge Cases & Common Calculation Mistakes
ℹ Underlying Algorithm Assumptions
- Assumes a discrete uniform distribution where every integer has equal probability of selection.
- Assumes proper entropy seeding from OS cryptographic pools (e.g., crypto.getRandomValues).
- Assumes range bounds satisfy min ≤ max.
⚠ 3 Common Mistakes to Avoid
- Using naive modulo operator `%` on random integers (e.g., `rand() % 6`), which creates modulo bias favoring lower numbers.
- Using standard Math.random() for security keys, passwords, or lotteries; Math.random() is a non-cryptographic PRNG.
- Allowing duplicates when the user intended "sampling without replacement" (like drawing lottery numbers).