2017 © Pedro Peláez
 

library markov

Markov Chain

image

scripturadesign/markov

Markov Chain

  • Saturday, January 30, 2016
  • by martindilling
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,608 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 2 Versions
  • 15 % Grown

The README.md

Markov Chain

Latest Version on Packagist [![GitHub Tests Action Status][ico-workflows]][link-workflows] ![Total Downloads][ico-downloads] Software License, (*1)

Markov Chain implementation.
You train it by giving it arrays of tokens. Then you can get the occurrences and probability of tokens after a given token., (*2)

Installation

You can install the package via composer:, (*3)

``` bash $ composer require scripturadesign/markov, (*4)


## Usage !!! Out of date, look in tests for now !!! ``` php /* Create a new first order Markov Chain object */ $chain = new Chain(1); /* Learn from arrays of tokens */ $chain->learn(['the', 'falcon', 'likes', 'the', 'snake']); /* Get all the history of the training */ $chain->history(); // [ // [ // 0 => [''], // 1 => ['the'], // 2 => ['falcon'], // 3 => ['likes'], // 4 => ['snake'], // ], // [ // 0 => ['the' => 1], // 1 => ['falcon' => 1, 'snake' => 1], // 2 => ['likes' => 1], // 3 => ['the' => 1], // 4 => ['' => 1], // ], // ]

``` php /* Create a new second order Markov Chain object */ $chain = new Chain(2);, (*5)

/* Learn from arrays of tokens */ $chain->learn(['the', 'falcon', 'likes', 'the', 'snake']);, (*6)

/* Get all the history of the training */ $chain->history(); // [ // [ // 0 => ['', ''], // 1 => ['', 'the'], // 2 => ['the', 'falcon'], // 3 => ['falcon', 'likes'], // 4 => ['likes', 'the'], // 5 => ['the', 'snake'], // ], // [ // 0 => ['the' => 1], // 1 => ['falcon' => 1], // 2 => ['likes' => 1], // 3 => ['the' => 1], // 4 => ['snake' => 1], // 5 => ['' => 1], // ], // ], (*7)


## Testing ``` bash $ composer test

Change log

Please see CHANGELOG for more information what has changed recently., (*8)

Contributing

Please see CONTRIBUTING for details., (*9)

Security

If you discover any security related issues, please email martindilling@gmail.com instead of using the issue tracker., (*10)

Credits

License

The MIT License (MIT). Please see License File for more information., (*11)

The Versions

30/01 2016

dev-rebuild_with_nth_order_support

dev-rebuild_with_nth_order_support https://github.com/scripturadesign/markov

Markov Chain

  Sources   Download

MIT

The Requires

  • php ^5.6|^7.0

 

The Development Requires

markov chain