Simple Markov Chain implementation. The model generates the next token according to the input token based on hardcoded input data.
build & run : guess how
Hardcoded data: {1,2,3,4,5,6,7,8,7,8,7,8,7,8,2,3,2,3,2,3,2,3}
Hardcoded data computed statistical model:
1 | stats:
2 : 1 : 1
2 | stats:
3 : 5 : 1
3 | stats:
2 : 3 : 0.75
4 : 1 : 0.25
4 | stats:
5 : 1 : 1
5 | stats:
6 : 1 : 1
6 | stats:
7 : 1 : 1
7 | stats:
8 : 4 : 1
8 | stats:
2 : 1 : 0.25
7 : 3 : 0.75
Generated output:
2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,4,5,6,7,8,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,4,5,6,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7,8,2,3,2,3,2,3,2,3,2,3,2,3,4,5,6,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7
As we can see, the output [token --> next token] sequences frequencies are valid according to the gathered data statistics.