University of Sydney · FACULTY OF MACHINE LEARNING

COMP4318 · Machine Learning and Data Mining

- one subject, every graph, every model, every mark
Machine Learning14 Chapters10-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 10 of 11 · COMP4318

Markov Models & Hidden Markov Models

Week 11 covers sequence models: Markov chains and the Markov property, hidden Markov models (states, emissions, transitions), and the inference algorithms — the Forward algorithm for an observation's probability and Viterbi for the most likely state sequence. Both sample exam papers include an HMM question, so the Forward/Viterbi recurrences are prime material; a Markov-chain sequence-probability calculation is a common lead-in. The homework quiz (h11) drills them.

In this chapter

What this chapter covers

  • 01Markov property: P(πₜ | π₁…πₜ₋₁) = P(πₜ | πₜ₋₁); transition matrix A and initial distribution A0
  • 02Sequence probability P(π1,…,πK) = P(π1)·Π P(πᵢ₊₁ | πᵢ)
  • 03Hidden Markov Model λ = (states, A, A0, emission matrix E); the states are hidden, only observations are seen
  • 04Problem 1 (Evaluation): probability of an observation sequence via the Forward algorithm
  • 05Forward recurrence: fₖ(1) = A0(k)·eₖ(x1); fₖ(i) = eₖ(xᵢ)·Σⱼ fⱼ(i−1)·aⱼₖ; P(X) = Σₖ fₖ(m)
  • 06Problem 2 (Decoding): most likely hidden-state sequence via Viterbi (max instead of sum, plus back-pointers)
  • 07Problem 3 (Learning): estimate the model λ from observations via EM
  • 08Complexity N²T for Forward/Viterbi versus naïve path enumeration; applications in POS tagging, speech and bioinformatics
Worked example · free

Probability of a state sequence in a Markov chain

Q [3 marks]. A weather Markov chain has states Sunny and Rainy, initial distribution P(Sunny) = 0.6, P(Rainy) = 0.4, and transitions P(Sunny|Sunny) = 0.8, P(Rainy|Sunny) = 0.2, P(Sunny|Rainy) = 0.3, P(Rainy|Rainy) = 0.7. Compute the probability of the sequence Sunny, Sunny, Rainy. (3 marks)
  • +1Use the Markov factorisation P(π1,π2,π3) = P(π1)·P(π2|π1)·P(π3|π2) — each state depends only on the previous one.
  • +1Substitute: P(Sunny)·P(Sunny|Sunny)·P(Rainy|Sunny) = 0.6·0.8·0.2.
  • +1Multiply: 0.6·0.8 = 0.48; 0.48·0.2 = 0.096.
P(Sunny, Sunny, Rainy) = 0.6·0.8·0.2 = 0.096.
Sia tip — In a hidden Markov model you can't read the states directly. To score an observation sequence you sum over all state paths with the Forward algorithm, fₖ(i) = eₖ(xᵢ)·Σⱼ fⱼ(i−1)·aⱼₖ; to find the single most likely state path you swap the sum for a max and keep back-pointers — that is Viterbi.
Glossary

Key terms

Markov property
The assumption that the next state depends only on the current state, not the earlier history: P(πₜ | π₁…πₜ₋₁) = P(πₜ | πₜ₋₁).
Transition matrix
The matrix A with aᵢⱼ = P(next = j | current = i) giving the probabilities of moving between states; paired with an initial distribution A0.
Hidden Markov Model
A Markov chain whose states are hidden and emit observations via an emission matrix E; defined by λ = (states, A, A0, E).
Emission probability
eₖ(x) = P(observation x | state k); how likely each hidden state is to produce each observation.
Forward algorithm
Dynamic programming that sums over all state paths to give the probability of an observation sequence: fₖ(i) = eₖ(xᵢ)·Σⱼ fⱼ(i−1)·aⱼₖ, then P(X) = Σₖ fₖ(m).
Viterbi algorithm
Like the Forward algorithm but taking the max instead of the sum and storing back-pointers, to recover the single most likely hidden-state sequence.
FAQ

Markov Models & Hidden Markov Models FAQ

What makes a model 'Markov'?

The Markov property: the future depends only on the present state, not on how you got there. So the probability of the next state is conditioned only on the current one, which is what lets you multiply one-step transition probabilities to score a whole sequence.

Forward vs Viterbi — when do I use each?

Use the Forward algorithm to compute the probability of an observation sequence (Problem 1, Evaluation) — it sums over all hidden-state paths. Use Viterbi to find the single most likely hidden-state sequence (Problem 2, Decoding) — it is the same recurrence but takes a max instead of a sum and keeps back-pointers so you can trace the path back.

What's the difference between a Markov chain and a hidden Markov model?

In a Markov chain the states are observed directly, so you can read off the sequence and multiply transition probabilities. In a hidden Markov model the states are hidden and you only see observations emitted by them (via the emission matrix), so you need the Forward algorithm to score observations and Viterbi to infer the likely states.

How much of the exam is Markov models?

Both mined sample papers include an HMM question, so the Forward and Viterbi recurrences and a Markov-chain sequence probability are worth rehearsing thoroughly. Confirm the exact weighting on Canvas and the unit outline, since the paper's structure can vary between offerings.

Study strategy

Exam move

Learn the two recurrences as a matched pair: Forward (sum over previous states, fₖ(i) = eₖ(xᵢ)·Σⱼ fⱼ(i−1)·aⱼₖ) for the probability of an observation sequence, and Viterbi (max plus back-pointer) for the most likely state path. Rehearse a small two- or three-step HMM by hand, filling a trellis column by column, and practise a Markov-chain sequence probability as the warm-up. Keep 'sum for probability, max for path' as your one-line memory hook. When a trellis column comes out wrong, ask Sia to recompute it step by step and check your transitions and emissions.

Working through Markov Models & Hidden Markov Models in COMP4318? Sia is AskSia’s AI Machine Learning tutor — ask any COMP4318 Markov Models & Hidden Markov Models question and get a clear, step-by-step explanation grounded in how COMP4318 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 12 of your University of Sydney subjects - and 1,000+ Bibles across every Australian university.
Sia - your COMP4318 tutor, unlimited, worked the way the exam marks it
The full 10-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$25/ month
30-day money-back · cancel in one tap · how it works
Unlock the full COMP4318 Bible + 12 University of Sydney subjects解锁完整 COMP4318 Bible + University of Sydney 12 门科目
$25/mo