# Understanding Markov Chains: A Simple Guide

## The Gist

Imagine you're watching someone shop at a supermarket. They've just picked up milk. Based on that, you can make a decent guess what they'll reach for next — perhaps bread, or cereal, or eggs. It's not a wild guess. It's informed by experience: people who buy milk tend to buy these other things too.

That's the whole idea behind a Markov chain. It's a way of predicting what comes next, based only on what just happened. Nothing more.

## A Kitchen Example

Let's make it concrete. Picture your morning routine. Most days, you might do something like this:

Wake up → Make tea → Read emails → Get dressed → Leave the house

That's a chain. Each step links to the next. A Markov chain is just a formalised version of this — a list of states and a set of probabilities telling you how likely you are to move from one to the next.

Now here's the clever part: to predict what you'll do at 9 AM, you don't need to know everything you did yesterday. You only need to know what you did at 8:45. The chain has no memory beyond the last step. That's what makes it "Markov."

## Where the Name Comes From

The concept is named after Andrey Markov, a Russian mathematician who lived in the early 1900s. He was interested in modelling systems that change randomly over time — things that aren't fully predictable, but aren't purely random either. His big insight was this: you can make surprisingly good predictions about a system's future just by looking at its current state, ignoring everything that came before.

At first, this sounds wrong. Surely older information helps? But for many real-world systems, it turns out not to matter much. And the maths becomes dramatically simpler.

## Rolling Dice vs Drawing Tiles

Think of two different games.

**Game one:** You roll a fair six-sided die. Each roll is completely independent. What you rolled before tells you nothing about what you'll roll next. That's pure randomness.

**Game two:** You have a bag of letter tiles, like Scrabble. The bag contains a fixed mix of letters. You draw one, note it down, and put it back. The next draw is still constrained by the contents of the bag. If you pull out a Q early on, the bag still has mostly non-Q tiles left — so another Q is unlikely for a while.

Markov chains are more like game two. The next state depends on the current one. There's randomness, but it's shaped — constrained by where you are right now.

## Internet Search and Your Next Click

This brings us to your proxy. When you browse the web, you leave a trail of links. A Markov chain can study that trail and notice patterns: after you click a Wikipedia article, you often click a related article. After a news story, you often click a comments section. The chain builds a map of likelihoods — a probability table for what comes after each link.

Then, when it needs to guess your next click, it doesn't consult your entire browsing history. It just looks at where you are now.

This approach is used widely. Google PageRank, which decides how important webpages are, borrows from Markov-style thinking. Language models — the kind that power autocomplete — use similar ideas to guess the next word in a sentence. Predicting stock prices, weather, or music playlists all draw on these same roots.

## The Limits

Markov chains are powerful, but they have a weakness: they're short-sighted. They only see one step back. If your behaviour follows a weekly cycle — you shop differently on Fridays, say — a simple Markov chain won't learn that pattern. It only knows what you did last.

More advanced models, like the ones behind modern language models, can look back further. They carry far more "memory." But they cost vastly more to run, and for many practical tasks, the humble Markov chain still does well.

## In Short

A Markov chain is a simple idea: predict the next thing based only on the current thing. That's it. No deep history. No complex reasoning. Just a table of probabilities built from observation, and a rule that says "where you are now is all that matters."

And yet, from that small foundation, you get a tool powerful enough to model language, rank web pages, predict behaviour, and — as you've discovered — anticipate which link someone might click next.