Hidden Markov Models: Definition
Motivation
Naive Bayes treats every observation independently: word order does not matter. But many real-world problems involve sequences where items depend on their neighbours: speech, weather patterns, financial time series, biological sequences (DNA, proteins). Hidden Markov Models explicitly model these temporal dependencies through a two-level structure: hidden states that evolve over time and visible observations emitted by those states.
Formal Definition:
An HMM models a system where we observe outputs (emissions) but cannot directly observe the underlying process (hidden states). The model is fully specified by five components:
| Symbol | Name | Description |
|---|---|---|
| Hidden States | The unobservable states: $S = {s_1, s_2, \ldots, s_{ | |
| Observations | The observable emissions: $V = {v_1, v_2, \ldots, v_{ | |
| Transition Matrix | — row , column | |
| Emission Matrix | — row , column | |
| Initial Distribution | — probability of starting in state |
Each row of sums to 1. Each row of sums to 1. .
Concrete Example: Weather HMM
This is the 2024 Q8 HMM. Hidden states: (air temperature, unobservable without a thermometer). Observations: (visible weather).
Transition matrix — models how temperature changes month to month:
| / | ||
|---|---|---|
Emission matrix — models the weather given the temperature:
| / | |||
|---|---|---|---|
Note: Snow requires freezing temperatures (). Rain implies above-freezing (). Dry is possible in either state.
Initial distribution : .
What Makes HMMs Different from Naive Bayes
Naive Bayes: — each word contributes independently. Word order does not matter. “The dog bit the man” and “The man bit the dog” are identical to NB.
HMMs model the dependence between consecutive items through the transition matrix . The hidden state at time depends on the hidden state at . The observation at time depends on the state at . This sequential structure makes HMMs suitable for any data where context matters: part-of-speech tagging, speech recognition, activity recognition, financial regime detection.
Dual-Tape Training Data
Training requires fully labelled sequences: both the hidden state and the observation at every timestep must be known. This is called dual-tape data. Example:
| Timestep | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|
| State () | L | M | H | H | H | M | M |
| Observation () | + | ++ | ++ | +++ | ++ | ++ | + |
From this we count transitions and emissions to estimate and .
Summary
| Component | Formula | Meaning |
|---|---|---|
| — | Set of hidden states (size $ | |
| — | Set of observable symbols (size $ | |
| Transition probability | ||
| Emission probability | ||
| Initial state probability | ||
| Rows sum to 1 | , | Valid probability distributions |
Past paper questions: y2024p3q8, y2025p3q9