Random module for JavaScript
JSrandom.randFloat(5);// <=> JSrandom.randFloat(0,5)
//=>1.4567891701389055
JSrandom.randFloat(-2,3);
//=>-0.37792440940529315
JSrandom.randInt(5);// <=> JSrandom.randInt(0,5)
//=>2
JSrandom.randInt(-2,3);
//=>-1
generator (function): A random number generator.defaut is the build-in uniform generator use MT19937
JSrandom.select("abcdefg");
//=>"f"
JSrandom.select([0,2,3,5,2,9,1],Math.random);
//=>5
number (Number): The element number to pick, defaut value is a random number between [1,array.length).
JSrandom.sample("abcdefg");
//=>["b", "e", "c", "a", "d", "f", "g"]
JSrandom.sample([0,2,3,5,2,9,1],3);
//=>[5, 0, 2]
JSrandom.shuffle("abcdefg");
//=>"bacdegf"
JSrandom.shuffle([0,2,3,5,2,9,1]);
//=>[0, 3, 2, 9, 5, 2, 1]
var generator = JSrandom.Uniform(0,10);
generator();
//=>2.0685795052296387
var generator = JSrandom.Gaussian(0,1);
generator();
//=>0.6532581496839591
var generator = JSrandom.Bernoulli(0.5);
generator();
//=>true
generator();
//=>false
(function): An instance of Binomial which return integer [ 0, upper ] , the probability obey the binomial distribution.
var generator = JSrandom.Binomial(10,0.5);
generator();
//=>8
generator();
//=>3
var generator = JSrandom.Cauchy(3,1);
generator();
//=>5.677625315054479
generator();
//=>-10.669827067906697
(function): An instance of Exponential which return random number obey the exponential distribution.
var generator = JSrandom.Exponential(3);
generator();
//=>0.21951388774858185
generator();
//=>0.15475914346331018
JSrandom.uniform();
//=>0.22049420430347985
JSrandom.gaussian();
//=>1.7041861226289101
JSrandom.bernoulli(0.8);
//=>true
JSrandom.exponential(3);
//=>0.29350827394207385
###Other generator