Markov Chains


A Markov Chain is a system that is capable of predicting (or “hallucinating”) future state based only on the current state. Because of the predictable patterns in language, his process lends itself well to generating strings of text that resemble the style of text that the chain has been “trained” on. Commonly, this is used in the field of machine learning to imitate written human language.


As an experiment in learning about Markov Chains and a demonstration in how simple it can be to construct a rudimentary chain in python, I wrote a simple python script that takes a bunch of Donald Trump’s tweets from 2016 that I downloaded from and trains a Markov Chain on the text. The chain then generates a series of sentences less than 140 characters long in the same style of writing. The project, which can be found here generated some of these gems:

I like your lies.
Crooked Hillary is too easy!
Tickets: President Obama ever discuss the real world! Ted Cruz is mathematically out of control.

#ThrowbackThursday #Trump2016 I will soon be making a big speech the night of the wonderful reviews of last night.

This is indeed a great honor to support our Veterans with you!

Will go back on for a great guy!

Join @mike_pence at the Grand Opening of my favorite places this morning, was unable to answer the call!

#Debate #BigLeagueTruth Hillary Clinton is not qualified.

A true honor to get it done anyway!

Quick stop in Johnstown, Pennsylvania, where jobs are being stolen by other countries.

Video: The Club for Growth letter- trying to belittle.

I will be swamped!

When you can’t say it - but media misrepresents!

A truly great champion and a must read!

Will soon be taken from her last show for lack of ratings, is even worse TPP approved.

Great meeting with the rest of the @NYTimes.

It is a hypocrite!

MAKE AMERICA SAFE AGAIN! Isn’t it sad that Republicans would allow this to be a great time!

Had great meetings with Republicans in the Republican version - amazing people!

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now