1 | // A library of seedable RNGs implemented in Javascript.
|
2 | //
|
3 | // Usage:
|
4 | //
|
5 | // var seedrandom = require('seedrandom');
|
6 | // var random = seedrandom(1); // or any seed.
|
7 | // var x = random(); // 0 <= x < 1. Every bit is random.
|
8 | // var x = random.quick(); // 0 <= x < 1. 32 bits of randomness.
|
9 |
|
10 | // alea, a 53-bit multiply-with-carry generator by Johannes Baagøe.
|
11 | // Period: ~2^116
|
12 | // Reported to pass all BigCrush tests.
|
13 | var alea = require('./lib/alea');
|
14 |
|
15 | // xor128, a pure xor-shift generator by George Marsaglia.
|
16 | // Period: 2^128-1.
|
17 | // Reported to fail: MatrixRank and LinearComp.
|
18 | var xor128 = require('./lib/xor128');
|
19 |
|
20 | // xorwow, George Marsaglia's 160-bit xor-shift combined plus weyl.
|
21 | // Period: 2^192-2^32
|
22 | // Reported to fail: CollisionOver, SimpPoker, and LinearComp.
|
23 | var xorwow = require('./lib/xorwow');
|
24 |
|
25 | // xorshift7, by François Panneton and Pierre L'ecuyer, takes
|
26 | // a different approach: it adds robustness by allowing more shifts
|
27 | // than Marsaglia's original three. It is a 7-shift generator
|
28 | // with 256 bits, that passes BigCrush with no systmatic failures.
|
29 | // Period 2^256-1.
|
30 | // No systematic BigCrush failures reported.
|
31 | var xorshift7 = require('./lib/xorshift7');
|
32 |
|
33 | // xor4096, by Richard Brent, is a 4096-bit xor-shift with a
|
34 | // very long period that also adds a Weyl generator. It also passes
|
35 | // BigCrush with no systematic failures. Its long period may
|
36 | // be useful if you have many generators and need to avoid
|
37 | // collisions.
|
38 | // Period: 2^4128-2^32.
|
39 | // No systematic BigCrush failures reported.
|
40 | var xor4096 = require('./lib/xor4096');
|
41 |
|
42 | // Tyche-i, by Samuel Neves and Filipe Araujo, is a bit-shifting random
|
43 | // number generator derived from ChaCha, a modern stream cipher.
|
44 | // https://eden.dei.uc.pt/~sneves/pubs/2011-snfa2.pdf
|
45 | // Period: ~2^127
|
46 | // No systematic BigCrush failures reported.
|
47 | var tychei = require('./lib/tychei');
|
48 |
|
49 | // The original ARC4-based prng included in this library.
|
50 | // Period: ~2^1600
|
51 | var sr = require('./seedrandom');
|
52 |
|
53 | sr.alea = alea;
|
54 | sr.xor128 = xor128;
|
55 | sr.xorwow = xorwow;
|
56 | sr.xorshift7 = xorshift7;
|
57 | sr.xor4096 = xor4096;
|
58 | sr.tychei = tychei;
|
59 |
|
60 | module.exports = sr;
|