UNPKG

924 BTypeScriptView Raw
1/**
2 * This is a port of Shawn Cokus's implementation of the original Mersenne Twister algorithm (http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/MTARCOK/mt19937ar-cok.c).
3 * MT has a very high period of 2^19937. Though the authors of xorshift describe that a high period is not
4 * very relevant (http://vigna.di.unimi.it/xorshift/). It is four times slower than xoroshiro128plus and
5 * needs to recompute its state after generating 624 numbers.
6 *
7 * ```js
8 * const gen = new Mt19937(new Date().getTime())
9 * console.log(gen.next())
10 * ```
11 *
12 * @public
13 */
14export class Mt19937 {
15 /**
16 * @param {number} seed Unsigned 32 bit number
17 */
18 constructor(seed: number);
19 seed: number;
20 _state: Uint32Array;
21 _i: number;
22 /**
23 * Generate a random signed integer.
24 *
25 * @return {Number} A 32 bit signed integer.
26 */
27 next(): number;
28}
29//# sourceMappingURL=Mt19937.d.ts.map
\No newline at end of file