Sequence models: Markov chains, hidden Markov models and state-space models
10 questions on autoregressive models, Markov chains of different orders, how parameters grow, and hidden-variable models such as hidden Markov models and Kalman filters.
- 10 questions
- Stopwatch
- Instant feedback
Sample questions
Play now ↑Answers stay hidden. Start the quiz to play them.
Sample 1
A first-order Markov chain over elements with K equal to 3 states has a conditional table for each element given its predecessor. How many free parameters does that table need?
- 3
- 9
- 6
How it works
- One question per screen. An answer is final once sent.
- You see right away whether you were right, with a short explanation.
- The stopwatch runs: on equal scores, the faster player ranks first.
- Only your best attempt counts, so replaying is never risky.
About this quiz
Predict the next word in a sentence, tomorrow's rainfall, the next note in a melody or the next amino acid in a protein: all are questions about sequences, and each raises the same modelling choice. How much of the past should the prediction depend on? If it depends on everything that came before, the model is completely general but enormously expensive and gives no help from structure. If it depends on nothing, the model ignores the order of the data altogether. Most useful models sit between these extremes, and this quiz walks through the choices.
You will begin with the general autoregressive model, in which every element is conditioned on all earlier ones, and see that in graph terms it is a fully connected graph that assumes nothing. At the other extreme sits the model that treats elements as independent. Between them is the Markov chain, in which each element depends only on the one before, and its relatives, in which it depends on the previous two or more. You will use the rules of d-separation to see what a first-order chain implies, and count the parameters of chains of various orders to see why higher orders quickly become impractical for discrete data.
The second half introduces a clever way of getting long memory from a small model: add a hidden variable at each step and let the hidden variables, not the observations, form the Markov chain. The result, called a state-space model, has the property that the observations are not Markov at any order, since every earlier observation can influence the next through the hidden chain. You will meet its two famous special cases: with discrete hidden variables it is a hidden Markov model, and with linear Gaussian variables throughout it is the linear dynamical system also known as a Kalman filter.
A few confusions are common. In a state-space model it is the hidden chain, and not the observations, that has the Markov property. A model that has the Markov property can be expressive enough for many tasks, and one that does not need not be complicated. And replacing the simple observation formulas by neural networks makes these old models far more flexible.
The quiz suits learners who know graphical models and conditional independence, and practitioners working with sequential data. It needs only counting. There are 10 questions, each with an explanation, and it takes about four minutes. Sequence models of this kind are the ancestors of many systems in use today, from speech recognition to the language models that predict the next word. The central trade-off they illustrate, between how much context a prediction may use and how many parameters that costs, is still the main design question in sequence modelling, and the hidden-variable trick of carrying a compact summary of the past forward in a state is a recurring idea. Having met it here, in its simplest probabilistic form, makes later architectures easier to follow.
Questions and answers
›How long does the quiz take?
About 3 to 4 minutes for 10 questions, at roughly 20 seconds each. An explanation follows each answer, with the parameter counts worked out in words.
›Do I need to know graphical models?
It helps to know that a directed graph describes a factorisation of a joint distribution and to have seen the idea of conditional independence. The quizzes on directed graphical models and on d-separation cover those. The questions here explain what they use.
›What is an autoregressive model?
It is a model in which each element of a sequence is predicted from all the earlier elements. It follows from repeated use of the product rule of probability, and in graph form every node has a link from each previous node. It is completely general, so by itself it encodes no assumptions about the structure of the sequence.
›What is a Markov chain?
It is a sequence model in which each element depends only on the element immediately before it, the first-order case. In graph form it is a simple chain of nodes. The distribution of the next observation, given all past observations, depends only on the latest one. Higher-order chains let it depend on the previous two or more elements.
›Why do higher-order chains become impractical?
For discrete variables with K states, a first-order chain needs a conditional table with K minus one parameters for each of the K values of the previous element. Each extra step of memory multiplies the number of conditioning contexts by K, so the number of parameters grows exponentially with the order, which soon becomes unmanageable.
›What is a state-space model?
It is a model with a hidden variable for each observation, in which the hidden variables form a Markov chain and each observation depends only on its own hidden variable. It satisfies the property that the hidden variable before a given step and the one after it are independent given the one at that step.
›Why are the observations in a state-space model not Markov?
Between any two observations there is a path through the hidden variables that is never blocked by observed nodes, so there are no conditional independence properties among the observations. Predictions of the next observation depend on all earlier ones, whatever the order, even though the number of parameters stays small.
›What are hidden Markov models and Kalman filters?
Both are state-space models. If the hidden variables are discrete, the model is a hidden Markov model, and the observations can be discrete or continuous. If the hidden and the observed variables are all Gaussian with linear dependences, the model is a linear dynamical system, also called a Kalman filter. Either can be made more flexible by using deep networks for the observation model.