| Recommend this page to a friend! | 
|  Download | 
| Info | Documentation |  Files |  Install with Composer |  Download | Reputation | Support forum | Blog | Links | 
| Ratings | Unique User Downloads | Download Rankings | ||||
| Not yet rated by the users | Total: 73 | All time:  10,232 This week: 43  | ||||
| Version | License | PHP version | Categories | |||
| probability-selector 1.0 | MIT/X Consortium ... | 7.4 | Algorithms, PHP 5, Statistics | 
Selection manager for choosing next elements to use from data source based on uniform distribution of selections.
use Smoren\ProbabilitySelector\ProbabilitySelector;
$ps = new ProbabilitySelector([
    // data     // weight  // initial usage counter
    ['first',   1,         0],
    ['second',  2,         0],
    ['third',   3,         4],
]);
foreach ($ps as $datum) {
    echo "{$datum}, ";
}
// second, second, first, second, third, third, second, first, third, second, third, third, second, first, third, ...
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
composer install
composer test-init
composer test
PHP Probability Selector conforms to the following standards:
PHP Probability Selector is licensed under the MIT License.
|  Files (14) | 
| File | Role | Description | ||
|---|---|---|---|---|
|  .github (1 directory) | ||||
|  src (1 file) | ||||
|  tests (3 files, 2 directories) | ||||
|    .scrutinizer.yml | Data | Auxiliary data | ||
|    codeception.yml | Data | Auxiliary data | ||
|    composer.json | Data | Auxiliary data | ||
|    LICENSE | Lic. | License text | ||
|    phpcs.xml | Data | Auxiliary data | ||
|    phpstan.neon | Data | Auxiliary data | ||
|    README.md | Doc. | Documentation | ||
|  Files (14) | / | tests | 
| File | Role | Description | ||
|---|---|---|---|---|
|  unit (1 file) | ||||
|  _support (1 file) | ||||
|    coding_standard.xml | Data | Auxiliary data | ||
|    unit.suite.yml | Data | Auxiliary data | ||
|    _bootstrap.php | Aux. | Auxiliary script | ||
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. | 
|  Install with Composer | 
|  | probability-selector-2023-02-27.zip 8KB | 
|  | probability-selector-2023-02-27.tar.gz 6KB | 
|  | Install with Composer | 
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% | 
 | 
 | 
| Applications that use this package | 
 If you know an application of this package, send a message to the author to add a link here.
 If you know an application of this package, send a message to the author to add a link here.