Chance machines

Step 1 of 6

Count the days

A table of what comes next

Why this matters. The next-word suggestions on a phone keyboard started as exactly this kind of table, and Google's original PageRank was a chain like this run over the whole web. It is also the direct ancestor of how a language model picks each next word. You build one from a weather diary first, then from words.

Here is three weeks of one town's weather. The question a Markov chain asks is small: given today, what are the chances for tomorrow? It deliberately forgets everything before today.

Those chances come from counting. Go through the diary in pairs of neighbouring days and count how often a sunny day was followed by a sunny one, by a rainy one, and the same after a rainy day.

The diagram turns your counts into chances as you go. The four numbers on its arrows are the whole model.

????sunnyrainy

Three weeks of weather, day 1 to day 21:

1sunny
2sunny
3sunny
4sunny
5rainy
6rainy
7rainy
8sunny
9sunny
10sunny
11sunny
12sunny
13sunny
14rainy
15rainy
16rainy
17rainy
18rainy
19rainy
20rainy
21sunny

How often was each kind of day followed by each kind of day?

sunny → sunny0
sunny → rainy0
rainy → sunny0
rainy → rainy0

after a sunny day: 0 sunny, 0 rainy of 0

after a rainy day: 0 sunny, 0 rainy of 0

Sign in to save your progress.