PHPackages                             leaditin/distribution - 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. leaditin/distribution

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

leaditin/distribution
=====================

Probability distribution service

1.0.1(8y ago)313MITPHPPHP ^7.0

Since Jul 4Pushed 8y agoCompare

[ Source](https://github.com/leaditin/distribution)[ Packagist](https://packagist.org/packages/leaditin/distribution)[ RSS](/packages/leaditin-distribution/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Leaditin\\Distribution
======================

[](#leaditindistribution)

A simple PHP API for distributing values based on their probabilities

[![Build Status](https://camo.githubusercontent.com/bfe32d689b6ba022db8ecd3d9ad5acaf21e1db61df6a6aa5fcff6e12a3603d19/68747470733a2f2f7472617669732d63692e6f72672f6c6561646974696e2f646973747269627574696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/leaditin/distribution)[![Code Quality](https://camo.githubusercontent.com/a553df1b4f151c51244b3dcb10d46f547cc02ee445835582d6059f30be45bdcd/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c6561646974696e2f646973747269627574696f6e2e737667)](https://scrutinizer-ci.com/g/leaditin/distribution)[![Code Coverage](https://camo.githubusercontent.com/857b5410f34e35def3334fb5f0e1abbcc17b766c72f98c397372d40df8f5771c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6c6561646974696e2f646973747269627574696f6e2e737667)](https://scrutinizer-ci.com/g/leaditin/distribution/code-structure)[![Latest Version](https://camo.githubusercontent.com/486d8e65d2c5952dc4f80b7ed3508d521b2033221581799c628839320ff80fd5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6561646974696e2f646973747269627574696f6e2e737667)](https://packagist.org/packages/leaditin/distribution)[![PDS Skeleton](https://camo.githubusercontent.com/a8ce1f2a7b71f101b18fc0393ba5bf89b7a5b1f9d08a31b658ca0eab0064c0f6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7064732d736b656c65746f6e2d626c75652e737667)](https://github.com/php-pds/skeleton)

Installation
------------

[](#installation)

The preferred method of installation is via [Composer](http://getcomposer.org/). Run the following command to install the latest version of a package and add it to your project's `composer.json`:

```
composer require leaditin/distribution
```

Usage
-----

[](#usage)

Imagine that you want to simulate creation of 100 users where each must have defined gender. You want to have 53% female and 47% male.

Imagine that you do not want to generate all female users and after that all male users, instead of that you want these records to be generated randomly.

This is where `Leaditin\Distribution` will help you:

```
use Leaditin\Distribution\Collection;
use Leaditin\Distribution\Distributor;
use Leaditin\Distribution\Element;
use Leaditin\Distribution\Exception\DistributorException;

$probabilities = new Collection(
    new Element('MALE', 53),
    new Element('FEMALE', 47)
);

$distributor = new Distributor($probabilities, 100);

# Create user with random gender
$user = new \User();
$user->gender = $distributor->useRandomCode();
$user->save();

# Create user with explicit gender
$user = new \User();
$user->firstName = 'Jon';
$user->lastName = 'Snow';
$user->gender = $distributor->useCode('MALE');
$user->save();
```

Credits
-------

[](#credits)

- [All Contributors](../../contributors)

License
-------

[](#license)

Released under MIT License - see the [License File](LICENSE) for details.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3283d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/05ace5e8872f342734c0424a5d7e6436c39386cf978d4c1675d3d4a9af2fecdb?d=identicon)[igorvuckovic](/maintainers/igorvuckovic)

---

Top Contributors

[![igorvuckovic](https://avatars.githubusercontent.com/u/25580555?v=4)](https://github.com/igorvuckovic "igorvuckovic (13 commits)")

---

Tags

distributiondistributorprobabilityleaditin

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/leaditin-distribution/health.svg)

```
[![Health](https://phpackages.com/badges/leaditin-distribution/health.svg)](https://phpackages.com/packages/leaditin-distribution)
```

###  Alternatives

[markrogoyski/math-php

Math Library for PHP. Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with matrices and vectors, Numerical analysis; special mathematical functions; Algebra

2.4k7.4M48](/packages/markrogoyski-math-php)[symfony/requirements-checker

Check Symfony requirements and give recommendations

2014.9M39](/packages/symfony-requirements-checker)[malenki/math

Library to deal with some mathematical stuff. Implemented or partially implemented mathematical concepts are: Complex number, Matrix, Normal distribution, Random, Angle, Random Complex, Descriptive Statistics, Parametric tests (Anova, Dependant t-Test) and Non-Parametric tests (Wilcoxon Signed-rank test, Wilcoxon-Mann-Whitney test, Kruskal-Wallis).

1625.0k](/packages/malenki-math)[irfa/php-gatcha

Simple Items Gatcha with PHP

352.4k](/packages/irfa-php-gatcha)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
