Random Number Generator
Generate random numbers in any range
Numbers
—
Related Calculators
Frequently Asked Questions
Are these numbers truly random?
No — these are pseudorandom numbers generated by Math.random(), a deterministic algorithm seeded by the system clock. Pseudorandom numbers look random and pass statistical tests, but they are predictable if you know the seed. For cryptographic purposes, use a cryptographically secure random number generator (CSPRNG).
How do I generate a random number in a specific range?
Formula: Math.floor(Math.random() * (max - min + 1)) + min for integers. For decimals: Math.random() * (max - min) + min. Example for 1-6 (dice): Math.floor(Math.random() * 6) + 1. In Python: random.randint(1, 6) or random.uniform(1.0, 6.0).
What is the uniform distribution?
Math.random() produces uniformly distributed numbers — each value in [0,1) is equally likely. After scaling to [min, max], the probability of any subrange is proportional to its length. This means generating 1-10 gives equal probability to each digit.
How do I shuffle a list randomly?
Fisher-Yates algorithm: for i from n-1 to 1, swap element[i] with element[Math.floor(Math.random() * (i+1))]. This gives exactly n! equally likely permutations. In Python: random.shuffle(list). In JavaScript: list.sort(() => Math.random() - 0.5) is biased — use Fisher-Yates instead.
What are random numbers used for?
Statistics and simulations (Monte Carlo methods), games (dice rolls, card shuffles), cryptography (key generation — must use CSPRNG), A/B testing randomization, statistical sampling, random art and music generation, lottery draws, password generation.