Markov Chains — ELI5

Imagine you are playing a board game. You land on a square, and where you go next depends only on the square you are standing on — not how you got there. You roll the dice and move.

That is a Markov chain. It is a system where the next step depends only on the current state, not on the history of all previous steps.

Here is a real example. Think about weather:

  • If today is sunny, there might be a 70% chance tomorrow is sunny and a 30% chance of rain.
  • If today is rainy, maybe there is a 40% chance of sun and a 60% chance of more rain.

You do not need to know last week’s weather. Today’s weather is enough to predict tomorrow’s. That set of probabilities — “given where I am now, here are the chances of where I go next” — is a Markov chain.

People use them everywhere:

  • Phone keyboards predict the next word you will type based on the word you just typed.
  • Board games like Monopoly can be analyzed as Markov chains — your next position depends only on your current square.
  • Text generators pick the next word based on the current word, producing sentences that sound surprisingly natural.
  • Google’s original PageRank treated the web as a Markov chain — a “random surfer” clicking links, with each click depending only on the current page.

In Python, a Markov chain is often just a dictionary of probabilities. Simple to build, powerful in practice.

One thing to remember: A Markov chain says “the future depends only on the present, not the past” — and that one simplification makes incredibly complex systems manageable.

pythonmathprobabilityalgorithms

See Also

  • Python Bayesian Inference How updating your beliefs with new evidence works — and why it helps computers make smarter guesses.
  • Python Convolution Operations The sliding-window trick that lets computers sharpen photos, recognize faces, and hear words in noisy audio.
  • Python Fourier Transforms How breaking any sound, image, or signal into simple waves reveals hidden patterns invisible to the naked eye.
  • Python Genetic Algorithms How computers borrow evolution's playbook — survival of the fittest, mutation, and reproduction — to solve problems too complicated for brute force.
  • Python Linear Algebra Numpy Why solving puzzles with rows and columns of numbers is the secret engine behind search engines, video games, and AI.