(...seed: unknown[]): RandomAlea Seeded pseudo-random number generator. DO NOT USE when security matters, use webcrypto APIs instead.
seed
unknown[]returns
RandomAlea Alea: a seedable pseudo-random number generator by Johannes Baagøe.
Supports variadic and string seeds (create_random_alea('my', 3, 'seeds')).
For numeric seeds, prefer create_random_xoshiro which is faster with equal quality.
DO NOT USE when security matters — use the Web Crypto API (crypto.getRandomValues) instead.
Alea 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 ~19% slower than Math.random (~12.2M ops/sec vs ~15.0M ops/sec).
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://github.com/nquinlan/better-random-numbers-for-javascript-mirror
2 declarations
(...seed: unknown[]): RandomAlea Seeded pseudo-random number generator. DO NOT USE when security matters, use webcrypto APIs instead.
seedunknown[]RandomAlea RandomAlea Alea: a seedable pseudo-random number generator by Johannes Baagøe.
Supports variadic and string seeds (create_random_alea('my', 3, 'seeds')).
For numeric seeds, prefer create_random_xoshiro which is faster with equal quality.
DO NOT USE when security matters — use the Web Crypto API (crypto.getRandomValues) instead.
Alea 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 ~19% slower than Math.random (~12.2M ops/sec vs ~15.0M ops/sec).
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() => numberversionstringseedsArray<unknown>