Advertisement

Random Number Generator

Generate random numbers instantly. Set your min, max, and quantity.

Results:

True vs. Pseudo-Random Numbers

Most software uses pseudo-random number generators (PRNGs) — deterministic algorithms seeded with a value. Cryptographically secure random numbers use hardware entropy sources and are unpredictable even if the algorithm is known.

Use Cases by Type

Probability & Expected Values

Is Math.random() secure for passwords?

No — Math.random() is a PRNG seeded from a small entropy source. It can be predicted if an attacker observes enough outputs. For password generation and cryptographic keys, always use crypto.getRandomValues() (browser) or crypto.randomBytes() (Node.js).

How do I generate a random number in JavaScript?

Basic: Math.floor(Math.random() * (max - min + 1)) + min. Cryptographically secure: const arr = new Uint32Array(1); crypto.getRandomValues(arr); const num = (arr[0] / 2**32) * (max - min) + min;. The crypto version uses OS-level entropy.

What distribution should I use for my simulation?

Uniform distribution (equal probability) is the default and suits dice, card draws, and random samples. Normal (Gaussian) distribution suits modeling natural variation (heights, errors). Poisson suits rare events over time (server requests per second). Choose based on your real-world model.