PHPackages                             handybitesize/distributed-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. handybitesize/distributed-random

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

handybitesize/distributed-random
================================

Generate random numbers from a range with a normal distribution. Allows skewing and rounding.

0.2(7y ago)0261MITPHPPHP &gt;=5.3.0

Since Aug 22Pushed 7y ago1 watchersCompare

[ Source](https://github.com/handybitesize/distributed-random)[ Packagist](https://packagist.org/packages/handybitesize/distributed-random)[ Docs](https://github.com/handybitesize/distributed-random)[ RSS](/packages/handybitesize-distributed-random/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (3)Used By (0)

DistributedRandom
=================

[](#distributedrandom)

### Normally distributed random values for PHP

[](#normally-distributed-random-values--for-php)

DistributedRandom allows you generate random values within a range enforcing normal distribution rahter than the uniform distribution rand() et al will give you.

Disclaimer. This may not be real math(s). I use it when generating random objects for testing. For example if I want to generate 2000 users in one of 4 user permission groups, if I randomise the user permission\_group\_id I can expected roughly 500 users in each. However I usually want the majority of generated users to be in the less permissive groups and only a few "admins" created. This library lets you do that by randomisng with a large skew towards the lower end.

You can see the sort of distributions in the demo script

```
php -S localhost:8080 demo/web.php
```

Setup
-----

[](#setup)

Add the library to your `composer.json` file in your project:

```
{
  "require": {
      "handybitesize/distributed-random": "0.*"
  }
}
```

Use [composer](http://getcomposer.org) to install the library:

```
$ php composer.phar install
```

Composer will install DistributedRandom inside your vendor folder. Then you can add the following to your .php files to use the library with Autoloading.

```
require_once(__DIR__ . '/vendor/autoload.php');
```

Alternatively, use composer on the command line to require and install DistributedRandom:

```
$ php composer.phar require handybitesize/distributed-random:0.*

```

### Minimum Requirements

[](#minimum-requirements)

- PHP 5.3

Usage
-----

[](#usage)

```
use HandyBiteSize\DistributedRandom\GenerateRandom;

//examples here

$randomise = new GenerateRandom();

//random double between 0 and 1 distributed around 0.5
$rand = $randomise->random();

//Array of 10 randon doubles between 0 and 1 distributed around 0.5
$rand = $randomise->randomArray(10);

//eg
//[0.50398172239527, 0.55248558880547, 0.25614964553752, 0.80148380196869, 0.58439718574973,
// 0.48014020914308, 0.73432188492932, 0.58615275804089, 0.34302056021055, 0.41324347746747]

//random double between 10 and 100 distributed around 10 and rounded to nearest 10
$rand = $randomise->random(10, 100, 10, 10);

// array of 10 as above
$rand = $randomise->randomArray(10, 10, 100, 10, 10);

// eg
// [10, 30, 20, 20, 20, 10, 10, 50, 20, 20]
```

Unit Tests
----------

[](#unit-tests)

To follow!

```
$ cd tests
$ phpunit
```

License
-------

[](#license)

Licensed under the MIT License.

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

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 ~5 days

Total

2

Last Release

2863d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/736731?v=4)[Handybitesize](/maintainers/Handybitesize)[@handybitesize](https://github.com/handybitesize)

---

Top Contributors

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

---

Tags

randomseeddistributionnormal distributionskew

### Embed Badge

![Health badge](/badges/handybitesize-distributed-random/health.svg)

```
[![Health](https://phpackages.com/badges/handybitesize-distributed-random/health.svg)](https://phpackages.com/packages/handybitesize-distributed-random)
```

###  Alternatives

[paragonie/random_compat

PHP 5.x polyfill for random\_bytes() and random\_int() from PHP 7

8.2k675.8M425](/packages/paragonie-random-compat)[ircmaxell/random-lib

A Library For Generating Secure Random Numbers

84031.5M126](/packages/ircmaxell-random-lib)[symfony/requirements-checker

Check Symfony requirements and give recommendations

2014.9M39](/packages/symfony-requirements-checker)[mistic100/randomcolor

Generate attractive random colors

2411.5M6](/packages/mistic100-randomcolor)[pragmarx/random

Create random chars, numbers, strings

714.4M5](/packages/pragmarx-random)[paragonie/random-lib

A Library For Generating Secure Random Numbers

703.5M26](/packages/paragonie-random-lib)

PHPackages © 2026

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