(seed?: number | undefined): RandomXoshiro Seeded pseudo-random number generator using the Xoshiro128** algorithm. DO NOT USE when security matters, use webcrypto APIs instead.
seed?
number | undefinedreturns
RandomXoshiro Xoshiro128**: a seedable pseudo-random number generator by Blackman & Vigna (2018). Recommended for reproducible randomness (testing, simulations, procedural generation).
DO NOT USE when security matters — use the Web Crypto API (crypto.getRandomValues) instead.
Xoshiro128** has a 2^128-1 period and passes BigCrush.
It uses pure 32-bit arithmetic (shifts, rotates, XOR, multiply)
making it very fast in JavaScript via Math.imul.
Xoshiro128** passes all 11 distribution quality tests at 10M samples,
performing on par with Math.random (V8's xorshift128+):
- mean, variance, chi-squared uniformity, Kolmogorov-Smirnov - lag-1 through lag-8 autocorrelation - runs test, gap test, permutation test (triples) - bit-level frequency (bits 0-7) - 2D serial pairs (25x25 through 200x200 grids) - birthday spacings (Marsaglia parameters)
Speed is near-native (~4% slower than Math.random) and ~18% faster than Alea
(~14.4M ops/sec vs ~15.0M and ~12.2M respectively).
To reproduce:
npm run benchmark_random_quality # distribution tests (N=1M)
npm run benchmark_random_quality -- --deep # thorough (N=10M, multi-trial)
npm run benchmark_random # speed comparison@see https://prng.di.unimi.it/ @see https://vigna.di.unimi.it/ftp/papers/ScrambledLinear.pdf
2 declarations
(seed?: number | undefined): RandomXoshiro Seeded pseudo-random number generator using the Xoshiro128** algorithm. DO NOT USE when security matters, use webcrypto APIs instead.
seed?number | undefinedRandomXoshiro RandomXoshiro Xoshiro128**: a seedable pseudo-random number generator by Blackman & Vigna (2018). Recommended for reproducible randomness (testing, simulations, procedural generation).
DO NOT USE when security matters — use the Web Crypto API (crypto.getRandomValues) instead.
Xoshiro128** has a 2^128-1 period and passes BigCrush.
It uses pure 32-bit arithmetic (shifts, rotates, XOR, multiply)
making it very fast in JavaScript via Math.imul.
Xoshiro128** passes all 11 distribution quality tests at 10M samples,
performing on par with Math.random (V8's xorshift128+):
- mean, variance, chi-squared uniformity, Kolmogorov-Smirnov - lag-1 through lag-8 autocorrelation - runs test, gap test, permutation test (triples) - bit-level frequency (bits 0-7) - 2D serial pairs (25x25 through 200x200 grids) - birthday spacings (Marsaglia parameters)
Speed is near-native (~4% slower than Math.random) and ~18% faster than Alea
(~14.4M ops/sec vs ~15.0M and ~12.2M respectively).
To reproduce:
npm run benchmark_random_quality # distribution tests (N=1M)
npm run benchmark_random_quality -- --deep # thorough (N=10M, multi-trial)
npm run benchmark_random # speed comparisonuint32() => numberfract53() => numberversionstringseednumber