Algorithms used
- Unseeded:
Math.random() — implemented as xorshift128+ in Chrome/V8 and Firefox/SpiderMonkey. Specification: ECMA-262 §21.3.2.27. Passes BigCrush statistical test suite. - Seeded: Mulberry32 by Tommy Ettinger — 32-bit quality PRNG, passes all Diehard tests. Deterministic: same seed always produces identical sequence.
Appropriate use cases
Games, educational simulations, statistical sampling, reproducible research (with seed), lottery number picking, raffle draws, and classroom activities. Applicable per IETF RFC 4086 for non-cryptographic randomness.
Not appropriate for
Cryptographic key generation, security tokens, password hashing salts, regulated gambling systems, or any application where mathematical unpredictability is a security requirement. For cryptographic use, call crypto.getRandomValues() directly (CSPRNG, built into all modern browsers).
Range mapping
Integer mapping uses Math.floor(random() × (max − min + 1)) + min — the standard modulo-free approach that avoids modulo bias for arbitrary integer ranges.