Random Number Generator Formula & How It Works
- random() generates uniform float in [0, 1)
- Integer in [a,b]: floor(random() × (b−a+1)) + a
- Computer RNG is pseudo-random (deterministic with seed)
- Cryptographic RNG: uses hardware entropy for security
Computer random number generators are pseudo-random: they use mathematical algorithms seeded with initial values (often system time or hardware entropy) to produce sequences that appear random. For statistics and simulations, pseudo-random is sufficient. For cryptography, use cryptographically secure RNG (CSPRNG).