- Random number generators fall into two categories: True RNG (hardware-based) and Pseudo-RNG (algorithm-based)
- Math.random() is fast but predictable -- crypto.getRandomValues() is cryptographically secure
- AFFLIGO's tool runs entirely in-browser with zero data sent to any server
- Use unique mode for raffles and lotteries to prevent duplicate winners
- Enable crypto-secure mode for passwords, tokens, and security-sensitive generation
- The spin wheel provides an animated visual reveal for single-number picks
- Modulo bias can skew results if the range does not evenly divide the RNG output
- Decimals are supported up to 5 decimal places for scientific and statistical use
What Is a Random Number Generator
A brief history of randomness and the tool that powers everything from lotteries to encryption.
A random number generator (RNG) is a computational algorithm, hardware device, or software tool that produces a sequence of numbers lacking any predictable pattern. The concept dates back thousands of years -- ancient civilizations used dice, bones, and lots to introduce randomness into decisions.
In the modern era, random number generators power everything from lottery draws and video game loot drops to cryptography and scientific simulations. Without reliable randomness, online security would collapse, statistical research would be biased, and games of chance would be rigged.
Ancient Origins
Dice made from animal bones date back to 3000 BC. The Chinese used sticks for divination during the Shang Dynasty. Romans tossed metal discs (tesserae) in games of chance.
The Computer Era
John von Neumann proposed the middle-square method in 1946 -- the first algorithm for generating pseudo-random numbers on a computer. Modern algorithms like Mersenne Twister are far more sophisticated.
Online RNG Tools
Browser-based RNG tools use JavaScript's Math.random() or the Web Crypto API to generate numbers instantly. They eliminate the need for hardware devices while maintaining statistical quality.
Why It Matters Today
Every secure connection you make online relies on cryptographic randomness. Passwords, encryption keys, session tokens, and two-factor authentication codes all depend on unpredictable random numbers.
Why Randomness Matters
From fair decisions to unbreakable encryption, randomness is the invisible force behind trust and security.
Randomness is not just about picking a lucky number. It is a fundamental requirement for fairness, security, and scientific validity. Without true randomness, outcomes can be predicted, manipulated, or biased.
Fairness
Raffles, giveaways, and classroom activities need unpredictable results so every participant has an equal chance. A predictable RNG undermines the entire purpose of a random draw.
Security
Encryption keys, passwords, and session tokens must be unpredictable. If an attacker can guess or compute your random values, they can decrypt your data or impersonate you.
Science
Monte Carlo simulations, randomized controlled trials, and statistical sampling all depend on random assignment to eliminate bias and produce valid results.
Gaming
Video game mechanics like critical hits, loot drops, and procedural generation rely on RNG to create varied, unpredictable gameplay experiences.
The quality of your randomness directly determines the integrity of your outcome. A biased RNG in a lottery can lead to legal disputes. A weak RNG in cryptography can lead to data breaches.
True Random vs Pseudo-Random
Understanding the critical difference between hardware-based and algorithm-based randomness.
Not all random numbers are created equal. The distinction between True Random Number Generators (TRNG) and Pseudo-Random Number Generators (PRNG) determines which applications they are suitable for.
| Feature | True RNG (TRNG) | Pseudo-RNG (PRNG) |
|---|---|---|
| Source | Physical phenomena (atmospheric noise, radioactive decay, thermal noise) | Mathematical algorithms seeded with an initial value |
| Predictability | Unpredictable -- no pattern exists | Predictable if the seed is known |
| Speed | Slower -- limited by physical measurement | Very fast -- billions of numbers per second |
| Reproducibility | Cannot be reproduced | Same seed produces same sequence |
| Best For | Cryptography, high-security applications | Games, simulations, general-purpose use |
PRNG algorithms include Linear Congruential Generator (LCG), Xorshift, and Mersenne Twister. Each uses a different mathematical formula to produce sequences that pass statistical randomness tests.
TRNG sources include atmospheric noise (used by Random.org), keystroke timing, mouse movements, and hardware random number generators (HRNG) built into modern CPUs.
Cryptographic Randomness (CSPRNG)
Why Math.random() is not enough for security and how the Web Crypto API solves the problem.
A Cryptographically Secure Pseudo-Random Number Generator (CSPRNG) is a PRNG that satisfies additional requirements making it suitable for cryptographic use. Even if an attacker knows some output values, they cannot predict future or past values.
In web browsers, the Web Crypto API provides crypto.getRandomValues(), which generates cryptographically secure random numbers. This is the gold standard for any security-sensitive application in the browser.
| Method | Security Level | Use Case |
|---|---|---|
| Math.random() | Low -- predictable with enough output | Games, animations, non-sensitive randomization |
| crypto.getRandomValues() | High -- cryptographically secure | Passwords, tokens, encryption keys, 2FA codes |
| Hardware RNG (HRNG) | Highest -- physical entropy source | Server-side key generation, high-security systems |
Never use Math.random() for generating passwords, API keys, or encryption secrets. Studies have shown that Math.random() outputs can be predicted after observing as few as 10 consecutive values.
How Computers Generate Random Numbers
Seeds, algorithms, and the mathematics behind pseudo-random sequences.
Computers are deterministic machines -- they cannot produce truly random numbers on their own. Instead, they use algorithms that take an initial value (called a seed) and apply mathematical transformations to produce a sequence of numbers that appear random.
The Seed
Every PRNG starts with a seed value. If you use the same seed twice, you get the same sequence. This is useful for reproducing experiments but dangerous for security. Common seed sources include the current time, system entropy pools, or user input.
The Algorithm
Popular algorithms include Linear Congruential Generator (simple but weak), Xorshift (fast and good statistical quality), and Mersenne Twister (excellent distribution, used by most programming languages by default).
The Output
The algorithm produces a sequence of numbers. For LCG, each number is computed as: next = (a * current + c) mod m. The constants a, c, and m are carefully chosen to maximize the period (how long before the sequence repeats).
The Period
Every PRNG eventually repeats. Mersenne Twister has a period of 2^19937-1 -- a number so large it will never repeat in practice. Poorly designed generators may repeat after just a few million values.
AFFLIGO RNG Tool Features
Unique mode, decimals, a crypto toggle, spin animation, and sort/format controls — what each does below.
AFFLIGO's Random Number Generator combines ease of use with advanced features that power users need. Every feature is designed with privacy and flexibility in mind.
Unique & Duplicate Modes
Toggle between allowing repeated numbers or ensuring every generated number is unique. Essential for raffles where you cannot pick the same winner twice.
Decimal Support
Generate numbers with up to 5 decimal places for scientific calculations, statistical sampling, and precise measurements beyond simple integers.
Crypto-Secure Toggle
Switch from standard Math.random() to the Web Crypto API for cryptographically secure generation when security matters.
Spin Wheel Animation
An engaging slot-machine-style animation for single-number picks. Perfect for raffles, classroom draws, and game nights.
Sort & Format Controls
Sort results ascending, descending, or leave in generation order. Format output as comma-separated values or one number per line.
Works Offline
Loads once, then generates without a connection — usable on stage or in classrooms with spotty wifi.
Step-by-Step Guide
Set the range, pick the toggles, hit Generate, copy the result — the four stages below.
Set the Range
Enter a minimum value and maximum value to define the boundaries. For example, min=1 and max=100 generates numbers between 1 and 100 inclusive.
Choose Options
- Unique-only: No duplicates -- each number appears at most once
- Decimal: Toggle on for fractional numbers with configurable precision
- Crypto-secure: Enable for security-sensitive generation via Web Crypto API
Generate Numbers
Click Generate to produce your random numbers. Use the sort controls (None / Ascending / Descending) and format controls (Comma / New Line) to arrange the output.
Copy or Spin
Click Copy All to save results to your clipboard. For a single number with a visual reveal, use the Spin Wheel for an animated slot-machine effect.
Random Number Distributions
Understanding uniform, normal, and other distributions -- and when to use each.
A probability distribution describes how random values are spread across a range. The distribution you choose determines which values are more likely to appear.
| Distribution | Shape | Common Use |
|---|---|---|
| Uniform | Every value equally likely | Raffles, lotteries, general-purpose RNG |
| Normal (Gaussian) | Bell curve -- most values cluster around the mean | Height, weight, test scores, natural phenomena |
| Exponential | Most values small, fewer large values | Waiting times, failure rates, queue lengths |
| Bernoulli | Only two outcomes (0 or 1) | Coin flips, binary decisions, success/failure |
| Poisson | Count of events in a time period | Arrivals per hour, defects per batch, calls per minute |
AFFLIGO's random number generator produces a uniform distribution by default -- every number in the range has an equal probability of being selected. This is the standard expectation for raffles, games, and general-purpose use.
Unique vs Duplicate Mode
When to allow repeats and when every number must be one-of-a-kind.
Duplicate mode (default) allows the same number to appear multiple times. This is correct for rolling dice, spinning a wheel, or simulating independent events where the same outcome can occur twice.
Unique mode ensures no number appears more than once. This is essential for assigning numbers to participants, picking multiple winners, or any scenario where repetition would cause problems.
| Scenario | Mode | Why |
|---|---|---|
| Raffle with 1 winner | Either | Only one number picked -- duplicates are irrelevant |
| Raffle with 3 winners | Unique | Cannot pick the same winner twice |
| Rolling a dice 10 times | Duplicate | Dice can land on the same face repeatedly |
| Assigning seat numbers | Unique | Each person gets one unique seat |
| Simulating coin flips | Duplicate | Heads or tails can occur any number of times |
| Picking lottery numbers | Unique | Each number on a ticket is unique |
When using unique mode, the maximum quantity you can generate is limited by the range size. You cannot generate 100 unique numbers from a range of 1-50.
Decimal Numbers vs Integers
Choosing between whole numbers and fractional precision for your use case.
Integers are whole numbers without fractional parts. They are the standard for raffles, lottery draws, seat assignments, and any scenario where only whole values make sense.
Decimal numbers include fractional parts and are essential for scientific calculations, statistical sampling, and any application requiring precision beyond whole values.
| Type | Example | Best For |
|---|---|---|
| Integer | 42 | Raffles, lottery, seat numbers, dice rolls, counting |
| 1 Decimal | 42.3 | Temperature readings, basic measurements |
| 2 Decimals | 42.37 | Currency, weight, distance measurements |
| 3 Decimals | 42.371 | Scientific experiments, precision engineering |
| 5 Decimals | 42.37129 | Statistical sampling, Monte Carlo simulations |
The Spin Wheel -- Visual Randomness
How the animated slot-machine reveal works and when to use it.
The Spin Wheel is a visual animation that cycles through random numbers before landing on a final result. It provides an engaging, game-like experience that adds excitement to single-number generation.
Unlike the standard Generate button which instantly shows results, the spin wheel creates suspense and anticipation. This makes it ideal for live events, classroom activities, and any scenario where the reveal moment matters as much as the result.
Best For
Raffles, classroom draws, game nights, live events, and any single-pick scenario where you want a dramatic reveal.
How It Works
The animation rapidly cycles through numbers in your specified range, gradually slowing down before landing on the final random result. The entire process takes about 1.5 seconds.
Spin Again
After the result is revealed, you can immediately spin again without re-entering your range settings. This is useful for picking multiple winners in sequence.
Use Cases: Raffles & Giveaways
How to run a fair, transparent random draw for any event.
Raffles and giveaways are the most common use case for online random number generators. The key requirement is fairness -- every participant must have an equal probability of being selected.
Assign Numbers to Participants
Give each participant a unique number. If you have 50 people, assign numbers 1-50. Keep a list mapping numbers to names for verification.
Set the Range
Set min=1 and max=50 (or however many participants you have). This ensures every person is equally likely to be picked.
Enable Unique Mode
If picking multiple winners, enable unique mode to prevent the same person from being drawn twice. For a single winner, either mode works.
Generate & Announce
Click Generate (or use the Spin Wheel for a live event). Announce the winning number and match it to your participant list.
Use Cases: Lottery & Gaming
How randomness powers games of chance and video game mechanics.
The lottery industry generates over $300 billion in annual revenue worldwide, and every draw depends on secure random number generation. Similarly, the video game industry uses RNG to create dynamic, unpredictable experiences.
Lottery Draws
Official lotteries use hardware random number generators (HRNG) or certified software CSPRNGs. Some use atmospheric noise, others use thermal noise from semiconductors.
Video Game Loot
Games like Fortnite, Diablo, and Genshin Impact use weighted RNG for loot drops. Rare items have lower probability, creating excitement and rarity value.
Critical Hits
RPGs and strategy games use RNG for critical hit chances, dodge probabilities, and random event triggers. A 25% crit chance means roughly 1 in 4 attacks will crit.
Procedural Generation
Games like Minecraft and No Man's Sky use RNG to generate entire worlds, ensuring each playthrough is unique.
Use Cases: Security & Passwords
Why cryptographic randomness is non-negotiable for security applications.
Every secure digital system depends on random numbers. Encryption keys, passwords, session tokens, two-factor authentication codes, and nonce values all require cryptographically secure randomness.
The Web Crypto API's crypto.getRandomValues() is the standard for generating secure random values in web browsers. AFFLIGO's crypto-secure toggle activates this API for any generation.
Do not use date/time, sequential numbers, or user-chosen values as passwords or encryption keys. These are predictable. Always use a CSPRNG to generate security-sensitive random values.
For password generation, combine random characters from multiple character sets (uppercase, lowercase, numbers, symbols). A 16-character password generated by a CSPRNG has more entropy than a 30-character user-chosen passphrase.
Use Cases: Science & Statistics
Monte Carlo simulations, sampling, and the role of randomness in research.
Randomness is the foundation of modern statistics and scientific research. Random sampling eliminates selection bias. Random assignment ensures experimental groups are comparable. Monte Carlo simulations use random sampling to solve complex mathematical problems.
Monte Carlo Methods
Named after the casino in Monaco, these methods use repeated random sampling to approximate complex calculations. Used in physics, finance, and machine learning.
A/B Testing
Randomly assign users to control and variant groups to measure the true impact of changes. Without random assignment, results are confounded by user differences.
Bootstrap Resampling
Generate confidence intervals by repeatedly sampling with replacement from your data. Requires high-quality random numbers to produce valid statistical estimates.
Permutation Tests
Test hypotheses by randomly permuting group labels. This non-parametric approach makes no assumptions about data distribution.
Common Mistakes & Misconceptions
The gambler's fallacy, streaks, and why "random" does not mean "equal."
The Gambler's Fallacy
If a coin lands heads 5 times in a row, the next flip is still 50/50. Past random events do not influence future ones. Each flip is independent. The universe does not "owe" you tails.
"Random" Does Not Mean "Equal"
If you flip a coin 10 times, getting 7 heads and 3 tails is perfectly normal. True randomness produces clusters and streaks. Forced equality (exactly 5 heads, 5 tails) is actually less random.
Hot Hand Fallacy
Basketball players who make several shots in a row are not "hot" -- they are just on a streak. Research shows shooting percentages remain constant regardless of recent makes or misses.
Small Sample Bias
Humans are terrible at recognizing randomness in small samples. We see patterns where none exist. A truly random sequence of 10 coin flips might be HHTHHHTHTH -- and that is perfectly normal.
Online vs Offline Generators
Privacy, convenience, and why browser-side generation is the safest choice.
Online generators like AFFLIGO run entirely in your browser. The JavaScript code executes locally, and no data is ever sent to a server. This makes them inherently private and safe for sensitive applications.
Offline generators include desktop applications, command-line tools, and hardware random number generators. These are useful when you need integration with local systems or maximum control over entropy sources.
| Generator type | Pros | Cons |
|---|---|---|
| Browser-side (AFFLIGO) | No downloads, instant access, 100% private, works on any device | Limited by JavaScript performance |
| Desktop App | Offline access, system integration | Requires installation, potential malware risk |
| Hardware RNG | True randomness from physical phenomena | Expensive, requires special hardware |
| Command-Line | Scriptable, fast, integrates with pipelines | Requires technical knowledge |
Best Practices
Choosing the right mode, range, and settings for your specific use case.
Match Mode to Scenario
Use unique mode for raffles, seat assignments, and any scenario where repeats cause problems. Use duplicate mode for dice rolls, coin flips, and independent events.
Enable Crypto When Needed
For passwords, tokens, and security-sensitive generation, always enable the crypto-secure toggle. For games, raffles, and general use, standard generation is sufficient.
Verify Your Range
Double-check your min and max values before generating. An off-by-one error can include or exclude the wrong boundary number.
Document for Transparency
For public raffles or giveaways, screenshot the generation settings and results. This provides proof of fairness and builds trust with participants.
Frequently Asked Questions
Answers to the most common questions about random number generation.
Related tools you might find useful:
Key Takeaways
- RNGs fall into two categories: True RNG (hardware-based, unpredictable) and Pseudo-RNG (algorithm-based, reproducible)
- Math.random() is fine for games and raffles but never use it for passwords, tokens, or encryption keys
- Enable the crypto-secure toggle for any security-sensitive generation -- it uses the Web Crypto API
- Use unique mode for raffles and lotteries to prevent duplicate winners
- The spin wheel adds excitement to single-number picks -- perfect for live events and classroom draws
- All generation happens in your browser -- no data ever leaves your device
- Decimals are supported up to 5 places for scientific and statistical use cases
- The gambler's fallacy is a trap -- past results never influence future random outcomes
I generated 100 numbers in range 1-100 with the crypto toggle on: the distribution looked even with no obvious clustering, uniques mode correctly refused an impossible request (10 uniques from 1-5), and the 1.5s animation ran the same duration on repeat runs.
Sources: MDN crypto.getRandomValues docs, NIST SP 800-90A randomness recommendations.
