https://github.com/calebwin/margin
a Markov chain compiler for the DOT language
https://github.com/calebwin/margin
compiler dot graph markov-chain python
Last synced: about 1 year ago
JSON representation
a Markov chain compiler for the DOT language
- Host: GitHub
- URL: https://github.com/calebwin/margin
- Owner: calebwin
- License: mit
- Created: 2018-09-29T16:34:12.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-02-18T02:58:50.000Z (over 7 years ago)
- Last Synced: 2025-03-23T18:50:54.361Z (over 1 year ago)
- Topics: compiler, dot, graph, markov-chain, python
- Language: Python
- Homepage:
- Size: 15.6 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Margin
Margin is an utterly useless compiler for Markov chains. You can specify your Markov chains as DOT graphs.
```dot
/* weather_markov_chain.dot */
digraph my_weather_markov_chain {
"rain" -> "sunny" [label = 0.5];
"hail" -> "snow" [label = 1.0];
"rain" -> "hail" [label = 0.7];
}
```
Margin will then compile the graph to a Python implementation of the Markov chain in a class.
```
python margin.py weather_markov_chain.dot
```
```python
# weather_markov_chain.py
class my_markov_chain:
.
.
.
```
And you can use it as follows
```python
my_weather_predictor = my_markov_chain("rain")
my_weather_predictor.step()
```