PRNG Algorithms
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
javascript
ruby
README.md

README.md

Pseudorandom Number Generators

Ruby

Run tests:

bundle
rake test

Usage

Linear Congruential Generator

@lcg = PRNG::LCG.new(
  modulus: 5, multiplier: 2, increment: 3, seed: 0
)

@lcg.generate #=> 3
@lcg.generate #=> 4
@lcg.generate #=> 1
@lcg.generate #=> 0

JavaScript

Run tests:

npm install -g jasmine
jasmine

Usage

Linear Congruential Generator

var lcg = new PRNG.LCG.instance({
  modulus: 5, multiplier: 2, increment: 3, seed: 0
});

lcg.generate(); // 3
lcg.generate(); // 4
lcg.generate(); // 1
lcg.generate(); // 0