1. Go to this page and download the library: Download smoren/probability-selector library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Smoren\ProbabilitySelector\ProbabilitySelector;
$ps = new ProbabilitySelector([
// data // weight
['first', 1],
['second', 2],
]);
foreach ($ps->getIterator(6) as $datum) {
echo "{$datum}, ";
}
// second, second, first, second, second, first
print_r($ps->export());
/*
[
['first', 1, 2],
['second', 2, 4],
]
*/
use Smoren\ProbabilitySelector\ProbabilitySelector;
$ps = new ProbabilitySelector([
// data // weight
['first', 1],
['second', 2],
]);
$ps->decide(); // second
$ps->decide(); // second
$ps->decide(); // first
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.