xor128, a pure xor-shift generator by George Marsaglia.
- Period:
2^128-1
. - Reported to fail: MatrixRank and LinearComp.
import {prng_xor128} from 'esm-seedrandom'
import {prng_xor128} from 'esm-seedrandom/esm/index.js'
import prng_xor128 from 'esm-seedrandom/esm/index.js'
// from a browser or deno environment
import {prng_xor128} from '//cdn.jsdelivr.net/npm/esm-seedrandom/esm/index.min.js'
import {prng_xor128} from '//cdn.jsdelivr.net/npm/esm-seedrandom/esm/xor128.min.js'
let myrng = prng_xor128('an example seed string', {state: true})
console.log(myrng()); // between 0.0 and 1.0 as f32
console.log(myrng.quick()); // between 0.0 and 1.0 as f32
console.log(myrng.double()); // between 0.0 and 1.0 as f64
console.log(myrng.int32()); // between -2147483648 and 2147483647
let mystate = myrng.state()
console.log(mystate); // a JSON-serializable object capturing the internal PRNG state
let dup_myrng = prng_xor128(null, {state: mystate})