05/02
2016
Wallogit.com
2017 © Pedro Peláez
Random element(s) with weight
You can install and manage BiasRandom by using Composer, (*2)
composer require wataridori/bias-random
Or add wataridori/bias-random into the require section of your composer.json file then run composer update, (*3)
$biasRandom = new wataridori/BiasRandom/BiasRandom();
$data = [
'wataridori' => 10,
];
$biasRandom->setData($data);
$biasRandom->addElement('Tran', 20);
$biasRandom->addElement('Duc', 30);
$biasRandom->addElement('Thang', 40);
// Random one element with weight.
$biasRandom->random();
// Random two elements
$biasRandom->random(2);
Just run phpunit to start test., (*4)