PHPackages                             fieg/markov - 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. fieg/markov

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

fieg/markov
===========

Implementation of MarkovChain algorithm in PHP

1.0(11y ago)2422MITPHP

Since May 14Pushed 11y agoCompare

[ Source](https://github.com/fieg/markov)[ Packagist](https://packagist.org/packages/fieg/markov)[ RSS](/packages/fieg-markov/feed)WikiDiscussions master Synced 1mo ago

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

Markov Chain
============

[](#markov-chain)

Implementation of MarkovChain algorithm in PHP.

[![Build Status](https://camo.githubusercontent.com/6a552c229d7399144d9b84c304e62c757bbbebb3801364b282806cb748138685/68747470733a2f2f7472617669732d63692e6f72672f666965672f6d61726b6f762e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/fieg/markov)

Getting started
---------------

[](#getting-started)

```
use Fieg\Markov\MarkovChain;

$sentences = [
    'my blue car',
    'red and blue flowers',
    'his blue car',
];

$chain = new MarkovChain();

foreach ($sentences as $sentence) {
    $tokens = explode(" ", $sentence);

    $chain->train($tokens);
}

$result = $chain->query("blue");
```

Which would result in:

```
array(2) {
  'car' =>
  double(0.66666666666667)
  'flowers' =>
  double(0.33333333333333)
}

```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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

4023d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5eceacbc3912547ac51ba584798cc5a7c1bfae49b714978f62b6e1af389307dd?d=identicon)[fieg](/maintainers/fieg)

---

Top Contributors

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

---

Tags

algorithmmachine-learningmarkovmarkov-chainphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fieg-markov/health.svg)

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

###  Alternatives

[mnito/round-robin

Round-robin schedule generation implementation in PHP

6169.4k](/packages/mnito-round-robin)

PHPackages © 2026

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