PHPackages                             frank-houweling/weighted-random - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. frank-houweling/weighted-random

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

frank-houweling/weighted-random
===============================

Library for generating a weighted random sample

1.0.1(6y ago)32.3k↓91.2%5MITPHPPHP ^7.3

Since Jul 27Pushed 6y ago1 watchersCompare

[ Source](https://github.com/FrankHouweling/weighted-random)[ Packagist](https://packagist.org/packages/frank-houweling/weighted-random)[ RSS](/packages/frank-houweling-weighted-random/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

Weighted random
===============

[](#weighted-random)

[![Build Status](https://camo.githubusercontent.com/a363e25dbaee86530fa371127f3ac8a44804c87f4c3efcacd4d8a72890697d87/68747470733a2f2f7472617669732d63692e6f72672f4672616e6b486f7577656c696e672f77656967687465642d72616e646f6d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/FrankHouweling/weighted-random)[![codecov](https://camo.githubusercontent.com/233301b19df6b6ed40dd75b33b5c7c8ea070098e60d94cb05c86454b315b92f3/68747470733a2f2f636f6465636f762e696f2f67682f4672616e6b486f7577656c696e672f77656967687465642d72616e646f6d2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/FrankHouweling/weighted-random)

This library is used to pick random values from a set of registered values, where values with a higher weight have a larger probability to be picked.

Installing
----------

[](#installing)

Install this library using composer.

```
composer require frank-houweling/weighted-random
```

Getting started
---------------

[](#getting-started)

Using this library is simple. Initiate the WeightedRandomGenerator, register the possible values, and start generating random values!

```
