PHPackages                             qmegas/php-rand-custom-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. qmegas/php-rand-custom-distribution

ActiveLibrary

qmegas/php-rand-custom-distribution
===================================

Random number generator with custom distribution

1.0.1(3y ago)179MITPHPPHP &gt;=7.0

Since Dec 2Pushed 3y ago1 watchersCompare

[ Source](https://github.com/qmegas/php-rand-custom-distribution)[ Packagist](https://packagist.org/packages/qmegas/php-rand-custom-distribution)[ RSS](/packages/qmegas-php-rand-custom-distribution/feed)WikiDiscussions master Synced today

READMEChangelog (2)DependenciesVersions (3)Used By (0)

Random number generator with custom distribution
================================================

[](#random-number-generator-with-custom-distribution)

Standard PHP functions like `rand` or `mt_rand` generate random numbers with normal distribution, however sometimes it required to generate random numbers with different distribution, for example [binomial distribution](https://en.wikipedia.org/wiki/Binomial_distribution).

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

[](#installation)

```
composer require qmegas/php-rand-custom-distribution
```

Requirements
------------

[](#requirements)

PHP &gt;= 7.0

Simple Example
--------------

[](#simple-example)

```
$generator = new \Qmegas\RandomGenerator(50, 150, function(float $i) {
	return $i * 100;
});
echo $generator->getNumber();
```

Class constractor receives 3 arguments: low-high bounds of generated numbers and distribution function. Distribution function receives float argument between 0 and 1 and should return some integer value &gt;= 0, see additional examples for better understanding.

Some Additional Examples
------------------------

[](#some-additional-examples)

  Normal Distribution ```
$generator = new \Qmegas\RandomGenerator($min, $max, function() {
	return 1;
});
```

    [![](./images/1.png)](./images/1.png) ```
$generator = new \Qmegas\RandomGenerator($min, $max, function(float $i) {
	return $i * 100;
});
```

    [![](./images/m1.png)](./images/m1.png) ```
$generator = new \Qmegas\RandomGenerator($min, $max, function(float $i) {
	return (1 - $i) * 100;
});
```

    [![](./images/p.png)](./images/p.png) ```
$generator = new \Qmegas\RandomGenerator($min, $max, function(float $i) {
	return (1 - $i) * 200 * $i;
});
```

    [![](./images/pr.png)](./images/pr.png) ```
$generator = new \Qmegas\RandomGenerator($min, $max, function(float $i) {
	return (2 * (1 - $i) * ($i ** 0.5) + ($i ** 2)) * 100;
});
```

    [![](./images/pr2.png)](./images/pr2.png) ```
$generator = new \Qmegas\RandomGenerator($min, $max, function(float $i) {
	return ($i ** 3) * 100;
});
```

    [![](./images/sr.png)](./images/sr.png) ```
$generator = new \Qmegas\RandomGenerator($min, $max, function(float $i) {
	return (3 * ((1 - $i) ** 2) * $i + ($i ** 3)) * 100;
});
```

    [![](./images/s.png)](./images/s.png) ```
$generator = new \Qmegas\RandomGenerator($min, $max, function(float $i) {
	return (1 / (1 + exp(-10 * ($i - 0.5)))) * 100;
});
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Every ~575 days

Total

2

Last Release

1409d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/15cc5fe0b879740331bac2e4f81ff31f0470a47740f8d243fe06fac4bc8e0fe0?d=identicon)[qmegas](/maintainers/qmegas)

---

Top Contributors

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

---

Tags

randomgeneratorcustom distribution

### Embed Badge

![Health badge](/badges/qmegas-php-rand-custom-distribution/health.svg)

```
[![Health](https://phpackages.com/badges/qmegas-php-rand-custom-distribution/health.svg)](https://phpackages.com/packages/qmegas-php-rand-custom-distribution)
```

###  Alternatives

[mistic100/randomcolor

Generate attractive random colors

2431.4M6](/packages/mistic100-randomcolor)[ihor/nspl

Non-standard PHP library (NSPL) - functional primitives toolbox and more

381368.5k](/packages/ihor-nspl)[nubs/random-name-generator

A library to create interesting, sometimes entertaining, random names.

135680.2k3](/packages/nubs-random-name-generator)[gladcodes/keygen

A fluent PHP random key generator.

119668.9k2](/packages/gladcodes-keygen)[genphrase/genphrase

Secure passphrase generator for PHP applications

118302.5k4](/packages/genphrase-genphrase)[hi-folks/rando-php

Random generator Library for PHP

12884.3k2](/packages/hi-folks-rando-php)

PHPackages © 2026

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