This is a simple implementation of the Markov Chain Algorithm.
It's a simple mathematical model for predicting the possibility of some event occurring, given some previous state.
It has many applications - from simple things, such as getting a (very rough) prediction of weather, given the weather of the last few days
...to more complicated things, such as generating psuedo-random messages from existing chat logs from Facebook Messenger or Discord DMs
It also supports generating a graph of all probabilities, like so:
The source code for this can be found on GitHub.