https://github.com/wataridori/bias-random
Random elements with specific bias
https://github.com/wataridori/bias-random
bias-random php random
Last synced: 6 months ago
JSON representation
Random elements with specific bias
- Host: GitHub
- URL: https://github.com/wataridori/bias-random
- Owner: wataridori
- Created: 2015-03-18T04:15:37.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-02-05T05:59:37.000Z (over 10 years ago)
- Last Synced: 2025-09-27T11:16:09.577Z (10 months ago)
- Topics: bias-random, php, random
- Language: PHP
- Homepage:
- Size: 3.91 KB
- Stars: 6
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
BiasRandom for PHP
==========
[](https://styleci.io/repos/32437387)
[](https://travis-ci.org/wataridori/bias-random)
[](https://packagist.org/packages/wataridori/bias-random)
[](https://packagist.org/packages/wataridori/bias-random)
[](https://packagist.org/packages/wataridori/bias-random)
[](https://packagist.org/packages/wataridori/bias-random)
## Requirement
* PHP >= 5.4
## Install
You can install and manage BiasRandom by using `Composer`
```
composer require wataridori/bias-random
```
Or add `wataridori/bias-random` into the require section of your `composer.json` file then run `composer update`
## Usage
```php
$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);
```
## Test
Just run `phpunit` to start test.