aranta
v0.0.3
Published
Simple and flexible randomization framework
Downloads
3
Maintainers
Readme
Aranta.js
Simple and flexible randomization framework.
Installation
via npm:
$ npm install aranta
via bower:
$ bower install aranta
Quck usage
in node.js:
var aranta = require('aranta')
var random = new aranta.Random(new aranta.Algo.LinearCongruential())
console.log(random.int())
console.log(random.bool())
console.log(random.float())
in browser:
<script type="text/javascript" src="dist/aranta.js"></script>
<script type="text/javascript">
var random = new aranta.Random(new aranta.Algo.LinearCongruential())
console.log(random.int())
</script>
or you can use it with RequireJS, AMD and LMD (i love it :kissing_closed_eyes:). For more info see how Browserify works.
Random
The main class for usage in your apps.
.constructor(algo)
Create newRandom
instance with specified algorithm..int([max])
Get random integer on interval [0, max]. Defaultmax
: 0xffffffff..float()
Get random float value on interval [0.0, 1.0]..bool([chance])
Get random boolean value with specified probability. Defaultchance
: 50..reset([seed])
Reset generator state with optionalseed
.
Algorithms
All algos have identical consrtuctors with optional parameters:
.constructor([seed], [options])
, where:
seed
initial randomizer seed. Default:Date.now()
options
object, unique to each algorithm
Library provides next PRNG algorithms:
Options:
multiplier
increment
Options:
j
lag Jk
lag K
Running tests
$ npm install
$ make test
License
MIT