Last updated:
Random Number Generator
Generate random numbers instantly with customizable ranges. Free random number generator for lotteries, games, statistics, and decision-making applications.
Random Number Generator
Generate random numbers, roll dice, flip coins, pick lottery numbers, draw cards, create teams, and make random selections with our comprehensive generator.
Details
Enter values above to see results.
Want to learn more? Browse our calculation guides and tutorials →
Reviewed by CalculatorApp.me Math & Statistics Team
Random Numbers: The Science of True Randomness
PRNGs vs. TRNGs, entropy sources, cryptographic security, and the math of fair randomization.
CSPRNG
Cryptographically secure pseudorandom generator
256 bits
Typical entropy for secure token generation
Mersenne Twister
Most widely used PRNG algorithm (period 2¹⁹⁹³⁷−1)
1955
Year RAND Corp published 1,000,000 Random Digits
What Is a Random Number Generator?
A random number generator (RNG) produces a sequence of numbers that cannot be predicted better than by chance. Computers — being deterministic machines — cannot produce truly random numbers without a physical entropy source, so they use pseudorandom number generators (PRNGs): algorithms that produce statistically random-appearing sequences from a seed value.
True random number generators (TRNGs) harvest entropy from physical processes: thermal noise, radioactive decay, atmospheric noise, or mouse movement timing. Services like Random.org use atmospheric noise to produce genuine randomness passed by all NIST statistical tests.
RNGs are critical in cryptography, statistical sampling, simulations, gaming, lotteries, key generation, and any application requiring unpredictability.
Common RNG Algorithms
X(n+1) = (a × X(n) + c) mod m Common params (Knuth MMIX): a = 6364136223846793005 c = 1442695040888963407 m = 2⁶⁴ Fast, simple. NOT cryptographically secure.
LCGs fail many randomness tests if parameters are poorly chosen. Never use for security.
Period: 2¹⁹⁹³⁷ − 1 State: 624 × 32-bit integers Init: seeded with 32-bit value Twist: XOR, shift operations Outputs: 32-bit or 64-bit integers Default PRNG in Python, Ruby, R, MATLAB
Passes Diehard and NIST tests. Used for simulations & statistics. Not CSPRNG.
Uses 256-bit key + 64-bit nonce
20 quarter-round ARX operations
Outputs keystream blocks (512-bit)
Used by: Linux /dev/urandom (2022+)
TLS 1.3, WireGuard VPN
Passes: all NIST 800-22 testsChaCha20 is the gold standard for fast, secure random generation in modern systems.
// Rejection sampling for fair // distribution without modulo bias: range = max − min + 1 min_valid = (2³² mod range) loop: r = secure_random_32bit() if r >= min_valid: return (r mod range) + min
Naive 'r mod range' creates modulo bias for non-power-of-2 ranges. Rejection sampling is correct.
PRNG vs. TRNG vs. CSPRNG
| Property | PRNG | TRNG | CSPRNG |
|---|---|---|---|
| Source | Algorithm + seed | Physical entropy | Algorithm + entropy seeding |
| Speed | Very fast | Slow (hardware limited) | Fast |
| Predictable? | Yes (if seed known) | No | No (forward secrecy) |
| Crypto safe? | No | Yes | Yes |
| Examples | Math.random(), Mersenne Twister | Random.org, /dev/random | ChaCha20, AES-CTR, /dev/urandom |
| Use cases | Simulations, games, stats | Lotteries, key seeds | Passwords, tokens, SSL/TLS |
History of Random Number Generation
Von Neumann's Middle-Squares
John von Neumann proposed the 'middle-squares method' — take a number, square it, extract the middle digits — as the first general PRNG algorithm for computers.
Lehmer Linear Congruential Generator
D.H. Lehmer published the first linear congruential generator (LCG), still the basis of many simple random functions in embedded systems.
RAND Corp publishes 1M Random Digits
RAND Corporation published 'A Million Random Digits with 100,000 Normal Deviates' — a physical book of random numbers generated by a randomizing machine, used in simulations and statistics.
Mersenne Twister algorithm
Matsumoto and Nishimura published Mersenne Twister (MT19937) with a period of 2¹⁹⁹³⁷−1 — still the default PRNG in Python, R, and many statistics packages.
NIST SP 800-90A (DRBG Standard)
NIST published the Deterministic Random Bit Generator standard, establishing approved algorithms (HMAC-DRBG, CTR-DRBG) for US government cryptographic randomness.
Linux switches default to ChaCha20
Linux kernel 5.17 switched /dev/urandom and /dev/random to use ChaCha20-based CSPRNG, replacing the legacy Yarrow algorithm.
Key References
NIST SP 800-90A
Recommendation for Random Bit Generators
Official US government specification for deterministic random bit generators used in cryptographic applications.
Matsumoto & Nishimura 1998
Mersenne Twister: A 623-Dimensionally Equidistributed PRNG
The seminal paper introducing the MT19937 algorithm, still the most widely deployed statistical PRNG globally.
Random.org
True Random Numbers from Atmospheric Noise
Generates randomness from atmospheric radio noise. Passes all NIST 800-22 statistical tests for randomness.
Bernstein et al.
ChaCha20 and Poly1305 for IETF Protocols (RFC 8439)
Specifies ChaCha20 as a CSPRNG and stream cipher widely used in TLS 1.3, WireGuard, and Linux.
RNG Myths vs. Facts
Math.random() in JavaScript is cryptographically secure.
Math.random() uses a PRNG (not CSPRNG). For passwords, tokens, or security-sensitive values, use window.crypto.getRandomValues() or crypto.randomBytes() (Node.js).
Repeating the same 'lucky' numbers improves lottery odds.
Each lottery draw is independent. Prior numbers have zero influence on future draws. All number combinations have identical probability.
Computers can generate truly random numbers.
Deterministic computers generate pseudorandom numbers. True randomness requires a physical entropy source (thermal noise, radioactive decay, atmospheric noise).
More decimal places in a PRNG seed means better randomness.
The quality of randomness depends on the algorithm, not seed length. A good CSPRNG with a short seed is far superior to a weak algorithm with a long seed.
Frequently Asked Questions
What is this random number generator using?▼
Is this random number generator suitable for lottery picks?▼
What is a seed in random number generation?▼
Can I use this to generate a random password?▼
What is the difference between uniform and normal distribution?▼
How do I generate a random number in Python?▼
What is modulo bias in random number generation?▼
Are lottery numbers truly random?▼
What is entropy in computing?▼
What is the Mersenne Twister?▼
What does crypto.getRandomValues() do?▼
How many bits of randomness do I need for a token?▼
References
Related Calculators
Explore All Math & Statistics Tools
Probability, combinatorics, statistics, and more — powerful math tools for every need.
Browse Math Calculators →