Hacker News new | ask | show | jobs
by localhostdotdev 2622 days ago
markov chains are very simple at their core (e.g. simple version could be: take the probability of the next word given the known probabilities of words that follow the previous word)

it can be implemented in a few lines of code, that's the beauty of it: https://github.com/justindomingue/markov_chains/blob/master/...

obviously then you could take the previous n words into account, tweak the starting word, add randomness, etc.

now replace "word" with "state" and "probability(next state | previous state)" to edges of a graph: https://static1.squarespace.com/static/54e50c15e4b058fc6806d...

and you got a generic markov chain :)

footnotes: p(A | B) is probability of A given B, e.g. p(rain | clouds) > p(rain | sun) :)