Random numbers: what "random" actually means and why it matters
Not all random number generators are equal. The difference between Math.random() and crypto.getRandomValues() is the difference between a predictable sequence and a genuinely unpredictable one — and for anything security-sensitive, only the second is acceptable.
Pseudo-random vs cryptographically random
Math.random() (used in most simple tools) generates numbers using a deterministic algorithm seeded from the current time. If you know the seed and the algorithm, you can predict every future output. For games and simulations this is fine. For passwords, lotteries, or security tokens — it is not.
crypto.getRandomValues() draws entropy from the operating system — hardware events, thermal noise, mouse movements — sources that are genuinely unpredictable. This is what password managers, two-factor tokens, and encryption libraries use. This tool uses crypto.getRandomValues() when available.
Uniform distribution
A good random number generator produces a uniform distribution: each value in the range is equally likely. If we generate 10,000 numbers between 1 and 10, each digit should appear roughly 1,000 times.
In practice, most generators have slight biases from modulo operations. For small ranges (like 1–100), these biases are statistically negligible.
Unique (no-repeat) generation
Generating N unique values from a range is a shuffle problem. We create an array of all values in the range, shuffle it using the Fisher-Yates algorithm (each swap uses a cryptographically random index), then take the first N items. This guarantees uniformity — every ordering is equally likely.
Common use cases
- Lotteries: Set Min/Max to the lottery range (e.g., 1–49), enable Unique, set count to 6
- Dice simulation: Min 1, Max 6, Count 1 (or 2 for two dice)
- Random sampling: For research or testing where you need an unbiased subset of IDs
- Randomised order: Generate unique numbers, sort by result — creates a random ordering
What this tool does not do
This tool generates uniform integers. It does not generate floating-point numbers, Gaussian (bell-curve) distributions, or cryptographic keys. For key generation, use a dedicated tool or library.