https://github.com/zya/markovian
The simplest way to create a markovian process using markov chains. 🔗
https://github.com/zya/markovian
generative javascript markov markov-chain
Last synced: 6 months ago
JSON representation
The simplest way to create a markovian process using markov chains. 🔗
- Host: GitHub
- URL: https://github.com/zya/markovian
- Owner: zya
- Created: 2017-02-23T00:42:24.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-24T10:25:01.000Z (about 9 years ago)
- Last Synced: 2025-04-03T09:21:20.532Z (11 months ago)
- Topics: generative, javascript, markov, markov-chain
- Language: JavaScript
- Homepage:
- Size: 132 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# markovian
The simplest way to create a markovian process using [markov chains](https://en.wikipedia.org/wiki/Markov_chain).
## Installation
```
npm i markovian
```
## Usage
```js
var markovian = require('markovian');
// create states
var zero = {
value: 'zero', // value
targets: [0, 1, 2], // target indices
probabilities: [0.25, 0.25, 0.50] // target probabilities
};
var one = {
value: 'one',
targets: [0, 2],
probabilities: [0.25, 0.75]
};
var two = {
value: 'two',
targets: [0, 1],
probabilities: [0.80, 0.20]
};
// create the model
var states = [zero, one, two];
var model = markovian.create(states);
// start generating
setInterval(function(){
var state = model.tick();
console.log(state);
}, 500);
```