PHPackages                             outcloud/geometric-array-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. outcloud/geometric-array-random

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

outcloud/geometric-array-random
===============================

This package can be used to get random value from an array with given probability for each value

1.0.1(8y ago)116.7kMITPHPPHP &gt;=7.1

Since Aug 23Pushed 8y ago1 watchersCompare

[ Source](https://github.com/OutCloud/GeometricArrayRandom)[ Packagist](https://packagist.org/packages/outcloud/geometric-array-random)[ RSS](/packages/outcloud-geometric-array-random/feed)WikiDiscussions master Synced 1w ago

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

GeometricArrayRandom
====================

[](#geometricarrayrandom)

This package can be used to get values of given array with given geometric probability

Examples:
---------

[](#examples)

### 'Together' Input Mode

[](#together-input-mode)

```
$matrix = [
    [1, 0.1], // value, probablility
    [2, 0.1],
    [3, 0.1],
    [4, 0.3],
    [5, 0.2],
    [null, 0.2],
];

$generator = new GeometricArrayRandom($matrix);
$result = $generator->nextNValues(10);  // possible result: [4, null, 5, 1, null, 5, 5, 4, null, 4]
$singleValue = $generator->nextValue(); // possible result : 4
```

### 'Separately' Input Mode

[](#separately-input-mode)

```
$matrix = [
    [1, 2, 3, 4, 5, null], // values
    [0.1, 0.1, 0.1, 0.3, 0.2, 0.2] // probabilities
];

$generator = new GeometricArrayRandom($matrix, GeometricArrayRandom::MODE_TWO_DIMENSIONS);
$result = $generator->nextNValues(10);  // possible result: [4, null, 5, 1, null, 5, 5, 4, null, 4]
$singleValue = $generator->nextValue(); // possible result : 4
```

Additional info
---------------

[](#additional-info)

- Sum of probabilities in single matrix must always be equal to 1.0 (Otherwise an exception will be thrown)
- Probability is 'float' value greater or equal to 0 and lower or equal to 1 (Otherwise an exception will be thrown)
- Each value must always have a probability assigned (Otherwise an exception will be thrown)

Installation:
-------------

[](#installation)

```
composer require outcloud\geometric-array-random
```

I'm using Semantic Versioning

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Total

2

Last Release

3190d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a71ff6ae76bede553308f22c471a029cf23536ab284f635ad2d6ec5d59da1750?d=identicon)[Macintoshx](/maintainers/Macintoshx)

---

Top Contributors

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

---

Tags

arraymathphpphp-libraryphp7probabilisticrandom

### Embed Badge

![Health badge](/badges/outcloud-geometric-array-random/health.svg)

```
[![Health](https://phpackages.com/badges/outcloud-geometric-array-random/health.svg)](https://phpackages.com/packages/outcloud-geometric-array-random)
```

###  Alternatives

[balbuf/drupal-libraries-installer

Install Drupal libraries via a simple listing in your composer.json file

13223.4k1](/packages/balbuf-drupal-libraries-installer)[edgaras/strsim

Collection of string similarity and distance algorithms in PHP including Levenshtein, Damerau-Levenshtein, Jaro-Winkler, and more

2423.0k](/packages/edgaras-strsim)

PHPackages © 2026

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