LCG

rng. LCG

# new LCG()

Linear Congruential Generator Learn more - wikipedia - rosettacode - ams
Source:
Example
import { rng } from 'mathform';

// ZX81 parameters
// (see wikipedia or ams links provided above for more parameters)
let modulus = 2 ** 16 + 1;
let multiplier = 75;
let increment = 74;
let seed = Math.floor(Math.random() * 2 ** 16);

// Create the LCG objet
let lcg = new rng.LCG(modulus, multiplier, increment, seed);

// Usage
lcg.step() // returns a random number where 0 <= number <= 2 ** 16

Classes

exports.LCG

Methods

# LCG#step() → {integer}

Iterates the algorithm once and returns the new seed
Source:
Returns:
Type
integer