Statistical sampling and simulations require large quantities of random numbers to model systems accurately. Monte Carlo simulations use millions of random numbers to estimate probabilities, model physical systems, or optimize complex functions. For example, estimating π: generate random points in a square, count those within an inscribed circle, ratio approximates π/4. Quality randomness ensures simulation accuracy; biased generators produce incorrect statistical results. For scientific research, validated RNG implementations and documented seeds enable reproducibility—other researchers can verify results using the same random sequence.
Game development uses random numbers for procedural content, unpredictable gameplay, and replayability. Generating random loot drops (damage 1-100), enemy behavior (attack probability), spawn positions (coordinates within map bounds), or level seeds (integer seeds for procedural generation) creates variety. For multiplayer games, synchronized random seeds ensure all players experience identical procedural content. For balanced gameplay, controlled random ranges prevent extreme outcomes—damage 90-110 (average 100 with ±10% variance) is more predictable than 1-200.
Security applications like password generation, token creation, and cryptographic nonces require cryptographically secure random numbers. Weak randomness enables prediction attacks: if attackers can guess random values, they forge tokens, crack passwords, or break encryption. Cryptographic RNGs use hardware entropy (timing jitter, thermal noise) and cryptographic algorithms to ensure unpredictability. For password generation, random numbers select characters from an alphabet; for session tokens, random numbers create unique identifiers resistant to enumeration attacks. Always use crypto.getRandomValues or equivalent for security-sensitive randomness.