PHPackages                             leigh/mt-rand - 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. leigh/mt-rand

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

leigh/mt-rand
=============

PHP implementation of the MT19937 algorithm

0.1.0(10y ago)1092.3k—8.4%6MITPHPPHP &gt;=5.5

Since Feb 25Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/lt/PHP-MT19937)[ Packagist](https://packagist.org/packages/leigh/mt-rand)[ Docs](https://github.com/lt/PHP-MT19937)[ RSS](/packages/leigh-mt-rand/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Mersenne Twister written in PHP
===============================

[](#mersenne-twister-written-in-php)

This library contains pure PHP implementations of the Mersenne Twister pseudo-random number generation algorithm.

There are 3 classes available

### `MersenneTwister\MT`

[](#mersennetwistermt)

This is the Mersenne Twister algorithm as defined by the algorithm authors.

It works on both 32 and 64 bit builds of PHP and outputs 32 bit integers.

```
$mt = new \MersenneTwister\MT();
$mt->init(1234); // mt_srand(1234);
$mt->int31();    // int31() per mt19937ar.c, positive values only
$mt->int32();    // int32() per mt19937ar.c, high bit sets sign
```

### `MersenneTwister\MT64`

[](#mersennetwistermt64)

This is the 64-bit Mersenne Twister algorithm as defined by the algorithm authors.

It works **only on 64 bit builds of PHP** and outputs 64 bit integers.

```
$mt = new \MersenneTwister\MT64();
$mt->init(1234);
$mt->int63();    // int63() per mt19937-64.c, positive values only
$mt->int64();    // int64() per mt19937-64.c, high bit sets sign
```

### `MersenneTwister\PHPVariant`

[](#mersennetwisterphpvariant)

This is the Mersenne Twister algorithm as defined in PHP 5.2.1+. It is slightly different from the original algorithm and outputs a different set of numbers.

It works on both 32 and 64 bit builds of PHP and outputs 32 bit integers.

```
$mt = new \MersenneTwister\PHPVariant();
$mt->init(1234);     // mt_srand(1234);
$mt->int31();        // mt_rand();

// Breaks on huge ranges (i.e. PHP_INT_MIN, PHP_INT_MAX)
// PHP also breaks on huge ranges, but breaks differently.
$mt->rand(min, max); // mt_rand(min, max);
```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance43

Moderate activity, may be stable

Popularity39

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.7% 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

3735d ago

### Community

Maintainers

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

---

Top Contributors

[![lt](https://avatars.githubusercontent.com/u/1503065?v=4)](https://github.com/lt "lt (18 commits)")[![vshih](https://avatars.githubusercontent.com/u/52390?v=4)](https://github.com/vshih "vshih (1 commits)")

---

Tags

randomPRNGRNGmersennetwister

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/leigh-mt-rand/health.svg)

```
[![Health](https://phpackages.com/badges/leigh-mt-rand/health.svg)](https://phpackages.com/packages/leigh-mt-rand)
```

###  Alternatives

[paragonie/random_compat

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

8.2k655.0M405](/packages/paragonie-random-compat)[ircmaxell/random-lib

A Library For Generating Secure Random Numbers

84130.2M119](/packages/ircmaxell-random-lib)[ruafozy/mersenne-twister

Pure-PHP Mersenne Twister

221.4M12](/packages/ruafozy-mersenne-twister)[savvot/random

Deterministic pseudo-random generators library with dozens of useful functions and several sources of randomness

21243.7k5](/packages/savvot-random)[mistic100/randomcolor

Generate attractive random colors

2431.4M6](/packages/mistic100-randomcolor)[skywarth/chaotic-schedule

Randomize scheduled command execution time and date intervals

12142.3k](/packages/skywarth-chaotic-schedule)

PHPackages © 2026

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