Markov Models and Hidden Markov Models

Learn how AI systems reason about a world that changes over time. Model a changing system with a Markov chain and find its long-run behavior, then add hidden states and noisy evidence to build hidden Markov models. Track the current state with filtering, predict ahead, revise past estimates with smoothing and find the most likely sequence of states with the Viterbi algorithm. Approximate these computations with particle filters, and apply the methods to robot localization, object tracking and speech recognition.

IntermediateLesson 7 of 10 in Artificial Intelligence Course

What you will learn

  1. Describe a system that moves between states over time, compute how likely a run of states is, predict where the system will be, and find its long-run behavior.
    • Describe a system as a Markov chain
      Name the states, write the transition model as a matrix or diagram, and compute the probability of a sequence of states.
    • Predict how the state distribution evolves
      Use the transition matrix to update a probability distribution over states one step at a time, and see how predictions forget their starting point.
    • Find and interpret stationary distributions
      Solve for the distribution a chain keeps once it reaches it, know when the chain converges to it, and use it to describe long-run behavior.
  2. Build models in which the true state is hidden and only noisy evidence is observed, and choose states, variables and parameters that make such models work for real problems.
    • Build a hidden Markov model
      Combine a hidden Markov chain with a sensor model, compute the joint probability of states and evidence, and name the questions such a model can answer.
    • Design temporal models for real problems
      Choose state variables, discretization and parameters so that the Markov assumptions are reasonable, and see how dynamic Bayesian networks extend hidden Markov models.
  3. Compute what the evidence says about the hidden states: track the current state, predict ahead, score the evidence, revise past estimates and find the single most likely sequence of states.
    • Track the current state with filtering
      Run the forward algorithm, alternating a prediction step and an evidence update, to keep an up-to-date belief about the hidden state.
    • Predict ahead and score the evidence
      Extend the belief into the future without new evidence, forecast the next observation, and compute how likely the observed evidence is under a model.
    • Revise past estimates with smoothing
      Use later evidence to improve the estimate of an earlier state with the forward–backward algorithm.
    • Find the most likely explanation with the Viterbi algorithm
      Find the single most probable sequence of hidden states, and see why it can differ from the most likely state at each step.
  4. Track a belief with a population of samples when the state space is too large or continuous for exact filtering, and judge how reliable that approximation is.
    • Run a particle filter step by step
      Represent a belief by particles, move them with the transition model, weight them by the evidence and resample.
    • Judge the accuracy and failures of particle filters
      Explain how the number of particles affects accuracy, recognize degeneracy and impoverishment, handle impossible evidence, and choose between particle, exact and Kalman filtering.
  5. Use Markov models, hidden Markov models and particle filters to locate moving objects and robots, recognize speech and label words in a sentence.
    • Track and localize moving objects
      Set up tracking and robot localization as filtering problems, compute a localization update, and recognize the extensions used in practice.
    • Recognize speech and label sequences
      Explain how hidden Markov models and Markov language models were combined to recognize speech, decode with Viterbi, tag parts of speech, and place these methods in current practice.

Hidden Markov Models study guide

5 chapters

1

Modeling change and equilibrium

A transition rule lets you turn a description of change into a probability model. Start by choosing states and reading the direction of each transition, then combine many possible paths into one distribution over the next step. Long-run behavior adds a separate question: whether those distributions settle into a common balance. Periodic and absorbing examples show why the existence of a balance is only part of the answer.

1.1 States, transitions, and paths

A changing system needs a state for each moment and a rule for moving to the next moment. A discrete-time Markov chain records these states at evenly spaced steps. Choose the state and time step together: daily weather and a robot's location every second describe different processes.

What the current state must contain

The first-order Markov property is

P(Xt+1∣X1,…,Xt)=P(Xt+1∣Xt).

Once the current state is known, earlier states add no information about the next one. This is conditional independence, not independence between consecutive states. Knowing yesterday's weather can help predict tomorrow's when today's weather is unknown.

A chain needs an initial distribution, P(X1), and a transition model. We use time-homogeneous transitions: the same probabilities apply at every step. Some AI texts call this a stationarity assumption. In probability theory, a stationary process has joint distributions unchanged by shifting time; fixed transitions alone do not ensure that. Starting a time-homogeneous chain in a stationary distribution does.

Read a transition matrix

For weather, let the states be Sunny (S) and Cloudy (C). Rows name the current state and columns the next state:

T=(0.80.20.40.6).

From Sunny, the next day is sunny with probability 0.8 and cloudy with probability 0.2. From Cloudy, those probabilities are 0.4 and 0.6. Every row sums to 1 because it lists every destination from one starting state. Columns need not sum to 1. A state diagram represents the same table with arrows, including arrows back to the same state.

Some books transpose this convention. Before calculating, read the definition of an entry: here Tij=P(Xt+1=j∣Xt=i). A correct set of numbers used in the wrong orientation gives the wrong prediction.

Multiply along a path

A particular path uses its initial probability and one transition for each move:

P(x1:n)=P(x1)∏t=2nTxt−1,xt.

If day 1 is certainly sunny, the path Sunny, Sunny, Cloudy, Cloudy has probability

1×0.8×0.2×0.6=0.096.

The first move contributes 0.8, the switch contributes 0.2, and staying cloudy contributes 0.6. Multiplying separate daily frequencies would discard the links between days. In a Bayesian network, those links are the arrows in X1→X2→X3→⋯.

Keep enough history in the state

A second-order model depends on the last two values. Turn it into a first-order model by defining the state as (yesterday, today). Two weather values then give four possible pairs. A transition from (Sunny, Cloudy) can lead only to a pair beginning with Cloudy, because adjacent pairs must overlap. For a process of order k, store the last k values together; the algorithms stay first-order, while the number of combined states grows.

Key Takeaways

  • The Markov property removes dependence on earlier states after conditioning on the present.
  • Rows of the transition matrix describe destinations from one current state.
  • A path probability multiplies the initial probability and its transitions.
  • Time-homogeneous transitions and stationary state distributions are different ideas.
  • Storing recent history together turns a higher-order chain into a first-order chain.

1.2 Predicting a distribution

A chain occupies one state at each time, but you may not know which one. A state distribution stores that uncertainty as a row vector. Its entries give the probabilities of the possible states, not fractions of time within a single step.

Add every route into a destination

To predict Sunny tomorrow, consider both ways to get there: today may be Sunny or Cloudy. Weight each transition by the probability of its starting state:

P(Xt+1=j)=∑ipt(i)Tij.

For the complete vector, this is pt+1=ptT. After k moves, pt+k=ptTk. This update is sometimes called the mini-forward algorithm, the evidence-free version of HMM filtering.

Work through the weather chain

Use rows (0.8, 0.2) from Sunny and (0.4, 0.6) from Cloudy. Start with a certainly sunny day: p1=(1,0). One move gives p2=(0.8,0.2). For day 3, the sunny contribution is 0.8×0.8=0.64 from Sunny and 0.2×0.4=0.08 from Cloudy. Add them to get 0.72. The cloudy contributions are 0.8×0.2=0.16 and 0.2×0.6=0.12, giving 0.28.

Thus p3=(0.72,0.28). One further update gives P(X4=S)=0.72×0.8+0.28×0.4=0.688 and P(X4=C)=0.312. Carry unrounded values between steps and round displayed results at the end.

Check the meaning and orientation

Each result must be nonnegative and sum to 1. Under the row convention, put the distribution on the left. Using Tp1𝖳 instead gives the column (0.8, 0.4), whose total is 1.2. That calculation selects the probabilities of reaching Sunny from two different starts; it does not distribute one starting belief among destinations.

The value 0.72 on day 3 means about 72% of many independent runs with a sunny day 1 will be sunny on day 3. It describes neither a fixed repeating weather pattern nor a day that is 72% sunny.

Why prediction stays manageable

A dense update over S states costs O(S2) operations. It summarizes all past paths in the current vector, so the cost per move stays the same as time grows. Listing every path from a known start would instead require St−1 paths at time t.

For this weather chain, successive sunny probabilities approach 2/3. If st=P(Xt=S), then st+1=0.4+0.4st. Subtracting 2/3 shows that the gap shrinks by a factor of 0.4 each step. Other chains can behave differently; convergence needs the conditions studied with stationary distributions.

You can also simulate a run. Draw the initial state, then draw from the transition row for the state currently occupied. From Sunny, a uniform random draw below 0.8 selects Sunny; a draw at least 0.8 selects Cloudy. Repeating many runs estimates the same predicted distribution and introduces the sampling idea used by particle filters.

Key Takeaways

  • Prediction adds contributions from every possible previous state.
  • With row vectors, use pₜ₊₁ = pₜT and pₜ₊ₖ = pₜTᵏ.
  • A distribution describes uncertainty at one time, not a deterministic schedule.
  • Dense prediction costs O(S²) per step and simulation can approximate it.

1.3 Long-run behavior and its limits

A distribution can stay unchanged even while individual runs keep moving. A stationary distribution describes this balance. It is useful for long-run forecasts, but its existence alone does not tell you whether a chain approaches it from a particular start.

Solve the balance equations

A stationary row vector satisfies π=πT together with ∑jπj=1 and nonnegative entries. For the weather chain, probability flowing from Sunny to Cloudy must balance probability flowing back:

0.2πS=0.4πC,πS+πC=1.

The first equation gives πS=2πC. Substitution gives 3πC=1, so π=(2/3,1/3). For a two-state chain with switching probabilities a from state 1 to 2 and b from 2 to 1, π1=b/(a+b) when a+b>0.

For more states, write one incoming-flow equation per state. Replace one with the sum-to-1 equation and solve the linear system. The balance equations alone leave the scale undetermined. Finally multiply the proposed vector by the matrix to check it.

For bike-share stations A, B, C, take rows (0.6, 0.2, 0.2), (0.1, 0.8, 0.1), and (0.2, 0.2, 0.6). The solution is (0.25, 0.5, 0.25). For example, incoming probability at B is 0.25(0.2)+0.5(0.8)+0.25(0.2)=0.5. Uniform probability would fail this check.

Separate three questions
QuestionFinite-chain result
Does a stationary distribution exist?Every finite chain has at least one.
Is it unique?Irreducibility is sufficient.
Does every starting distribution approach it?Irreducibility plus aperiodicity is sufficient.

Irreducible means every state can reach every other state, possibly through several moves. Aperiodic means returns are not locked into a fixed cycle longer than one step. The weather matrix has all entries positive, so both conditions hold. In a finite irreducible chain, stationary probabilities also give the long-run fractions of steps spent in each state, even when periodicity prevents convergence of the time-specific distribution.

Two revealing counterexamples

If two states always swap, the distribution from a certain first state alternates between (1, 0) and (0, 1). The unique stationary vector is (0.5, 0.5), but these predictions never approach it. Along a long run, each state still occupies half the steps.

If both states are absorbing, each stays where it is forever. Every vector (q, 1 − q) is stationary, so there is no unique equilibrium shared by all starts. These examples show why uniqueness, convergence, and time averages need separate checks.

The initial distribution describes the start; it equals a stationary distribution only when you start in equilibrium. Fixed transition probabilities describe the model's law, not its current distribution. PageRank uses stationary probabilities to rank pages in a random-surfer model. Markov chain Monte Carlo constructs a chain with a desired stationary distribution so its long run can supply samples.

Key Takeaways

  • A stationary vector is nonnegative, sums to 1, and satisfies π = πT.
  • Balance equations need a normalization equation to fix their scale.
  • Every finite chain has a stationary distribution.
  • Finite irreducible chains have a unique stationary distribution and matching long-run time fractions.
  • Aperiodicity also ensures convergence from every start in a finite irreducible chain.
  • Periodic or reducible chains require separate checks of their long-run behavior.
2

Building models with hidden states

A reading can be perfectly observed while the state that produced it remains uncertain. Hidden Markov models separate the movement of that state from the noise in the observations. Choosing enough information for the state makes these assumptions useful; choosing too much can make inference costly. Parameter counts, training records, and sensor outliers give practical ways to judge and improve a model before running it.

2.1 Hidden states and noisy observations

A sensor reading gives evidence about a state without revealing it perfectly. In a hidden Markov model, or HMM, the state changes over time and each state produces an observation. A robot may know what its range sensor reported while remaining uncertain about its position.

Specify three probability models

An HMM needs an initial state distribution, a transition model, and a sensor model:

P(X1),P(Xt+1∣Xt),P(Et∣Xt).

The hidden state is a discrete variable. The sensor model, also called the emission or observation model, tells you the likelihood of each observation in each state. We put a prior directly on X1 and observe E1 there. Texts that start with an unobserved X0 perform a transition before the first observation instead.

The state has the first-order Markov property. The observation at a time depends only on that time's state: P(Et∣X1:t,E1:t−1)=P(Et∣Xt). In a Bayesian network, draw a hidden-state chain and add an arrow from each state to its observation.

Build the solar-panel model

The hidden weather is Sunny or Cloudy, with transition rows (0.8, 0.2) and (0.4, 0.6). Both initial states have probability 0.5. Daily panel output is High or Low:

Hidden weatherHighLow
Sunny0.80.2
Cloudy0.30.7

Each sensor row sums to 1. A cloudy day can still produce High output, so High does not identify Sunny with certainty. Likewise, P(L∣C)=0.7 is a statement about output on cloudy days. Finding P(C∣L) also needs the prior and Bayes' rule.

Score states and evidence together

For a particular state path and observation sequence,

P(x1:t,e1:t)=P(x1)P(e1∣x1)∏i=2tTxi−1,xiP(ei∣xi).

For Cloudy, Cloudy, Sunny with Low, Low, High, start at 0.5×0.7=0.35. Staying cloudy and observing Low gives 0.35×0.6×0.7=0.147. Switching to Sunny and observing High gives 0.147×0.4×0.8=0.04704.

Observations can be dependent even though they have no direct arrows between them. Persistent cloudy weather makes successive Low readings tend to occur together. Conditioning on the hidden states removes that dependence. Evidence updates the observer's belief; observing Low does not itself make the weather change.

Choose the inference question
TaskQuantity requested
FilteringCurrent state given evidence so far
PredictionFuture state given evidence so far
SmoothingEarlier state given later evidence too
Viterbi decodingOne most likely complete state path
Evidence likelihoodProbability of the observation sequence

The same three models support all five tasks. What changes is which variables you retain, which you sum out, and whether you sum over paths or select the largest path score.

Key Takeaways

  • An HMM combines a hidden chain, a prior, and a sensor model.
  • An observation depends on its current hidden state under the sensor assumption.
  • Sensor likelihoods and state posteriors condition in opposite directions.
  • Joint path-and-evidence probabilities include one emission per observed step.
  • Filtering, prediction, smoothing, decoding, and likelihood answer different questions.

2.2 Choosing states and learning model parameters

The state definition decides what the model can remember. A useful temporal model keeps the information needed to predict the next state, while keeping inference affordable. Its probabilities must also reflect the data and sensor failures it will encounter.

Choose enough state information

Position alone may be inadequate for an object with momentum: earlier positions reveal its direction. Adding velocity lets the current state explain that direction. Add season if the dynamics depend on it. These choices make the Markov approximation more reasonable; they are choices about what information travels forward.

A continuous quantity can be placed on a grid. Temperatures from 10 °C to 20 °C in 0.1 °C increments give 101 values, including both endpoints. Finer spacing increases the number of states. Combining several gridded quantities multiplies their counts, and dense exact inference costs O(S2) per step.

Count independent parameters

A categorical row with r entries has r−1 free parameters because the last entry is fixed by their sum. With S states and O observation values, an unrestricted HMM therefore needs

S−1+S(S−1)+S(O−1)

free parameters: prior, transitions, and emissions. The two-state, two-output solar model needs 1+2+2=5. Counting every table entry would count the row-sum constraints as additional choices.

Factor the state with a dynamic Bayesian network

A dynamic Bayesian network (DBN) keeps several state variables and gives each its own parents. It can express local dependencies without constructing a huge flat transition table. Twenty Boolean variables have 220=1,048,576 joint states; a flat transition table has 240 entries. If each next-step Boolean variable has three Boolean parents, its table needs eight probabilities, so all 20 need 20×8=160.

A discrete DBN can be flattened into an HMM by treating a complete assignment as one state. Factored storage is compact, but exact inference can still become costly when dependencies couple many variables. Particle methods can sample these assignments directly.

Estimate rows from data

When states are labeled, use conditional counts. Forty sunny successors out of 50 recorded transitions from Sunny give P(S→S)=40/50=0.8. The denominator counts transitions leaving Sunny, not every day in the record. A state at the end of a record has no observed successor.

Zero counts produce zero maximum-likelihood probabilities. Add-one correction gives each destination one pseudo-count and increases the row total accordingly. This avoids ruling out a transition solely because a small training record missed it. When states are hidden, Baum–Welch alternates smoothed expected counts with parameter re-estimation.

Give failures a place in the sensor model

If every possible state assigns zero likelihood to a reading, an update has zero total and cannot normalize. A small outlier component can give unusual readings some probability. A normalized mixture has the form P(e∣x)=0.99Pregular(e∣x)+0.01Poutlier(e). Both component distributions must be normalized.

The effect of a reading depends on likelihood ratios across states. Equal likelihoods leave the predicted belief unchanged after normalization. A small likelihood under every state can still be informative if the likelihoods differ greatly in relative terms.

Key Takeaways

  • Choose state variables that carry the history needed for the next step.
  • Finer grids and combined variables enlarge the state space.
  • Row-sum constraints reduce the number of free parameters.
  • DBNs store local conditional models without a full joint transition table.
  • Labeled states permit counting; hidden states can be learned with Baum–Welch.
  • A normalized outlier mixture can keep unusual sensor readings possible.
3

Estimating states across time

The same observations support different questions about time. Tracking the present requires a forward belief update; forecasting moves that belief ahead; reconstructing the past adds a backward pass. Selecting one complete explanation changes addition over paths into maximization. Working through these operations on the same solar-panel model makes the differences visible in both their arithmetic and their interpretation.

3.1 The forward algorithm

Filtering tracks the current hidden state using every observation available so far. Its output is a belief distribution, ft(x)=P(Xt=x∣e1:t). You update this compact distribution when a new reading arrives, without retaining every possible earlier path.

Predict, weight, normalize

For a later step, first move the belief through the transition model:

fˉt+1(j)=∑ift(i)Tij.

Then weight each destination by the likelihood of the new observation and normalize:

ut+1(j)=P(et+1∣j)fˉt+1(j),ft+1(j)=ut+1(j)∑rut+1(r).

The prediction describes where the state may have moved. The evidence update is Bayes' rule at the new time. With a prior on X1, start by weighting that prior with the first observation; there is no move before it.

Day 1: observe Low

Use the solar-panel model: prior (0.5, 0.5), transition rows (0.8, 0.2) and (0.4, 0.6), and Low likelihoods (0.2, 0.7). Weighting gives 0.5(0.2)=0.10 for Sunny and 0.5(0.7)=0.35 for Cloudy. The total is 0.45. Divide each weight by it to get f1=(2/9,7/9)≈(0.2222,0.7778).

Day 2: observe Low again

Prediction gives fˉ2(S)=(2/9)(0.8)+(7/9)(0.4)=22/45≈0.4889. Cloudy has probability 23/45≈0.5111. The new weights are 22/225≈0.0978 and 161/450≈0.3578. Their total is 41/90≈0.4556, producing f2=(44/205,161/205)≈(0.2146,0.7854).

The second Low only slightly increases the cloudy belief. Motion toward the chain's sunny-heavy equilibrium competes with the new evidence favoring Cloudy. Applying Low directly to yesterday's belief would miss that movement.

Day 3: observe High

Predict fˉ3=(498/1025,527/1025)≈(0.4859,0.5141). High has likelihoods (0.8, 0.3), so the weights are approximately (0.3887, 0.1542). Divide by their total, approximately 0.5429, to obtain f3≈(0.7159,0.2841).

High is 0.8/0.3≈2.67 times as likely under Sunny as under Cloudy. That likelihood ratio shifts the odds toward Sunny. A large likelihood alone is less informative than its size relative to the competing state's likelihood.

Keep an online filter reliable

A dense step costs O(S2) time and stores O(S) belief entries, independent of the length of the history. This is exact variable elimination: each past state is summed out as you advance.

Normalize at each observation. Without scaling, the vector stores joint state-and-evidence probabilities, which can shrink below floating-point range. Keep the discarded totals separately if you need evidence likelihood. A zero total requires model or particle-support recovery; division cannot repair it.

Our row-vector formula is ft+1∝(ftT)Ot+1, where the diagonal matrix contains the new likelihoods. For column beliefs the equivalent is ft+1∝Ot+1T𝖳ft. Mixing these conventions is a frequent source of errors.

Key Takeaways

  • Filtering estimates the current state given observations so far.
  • The first observation weights the prior directly.
  • Each later observation follows prediction, likelihood weighting, and normalization.
  • Likelihood ratios determine how evidence shifts relative state beliefs.
  • Normalization controls numerical scale; retain update totals to score evidence.
  • Dense filtering uses O(S²) time per step and O(S) belief memory.

3.2 Forecasts and evidence likelihood

A filtered belief supports two useful questions: what might happen next, and how well did the model explain the readings already seen? Both use the same transition and sensor models, but the answers describe different random quantities.

Predict without future readings

For a forecast k steps ahead, apply the transition matrix k times to the latest filtered belief:

P(Xt+k∣e1:t)=ftTk.

No observation update belongs to an unobserved future step. After the solar model sees Low, Low, High, the day-3 belief is approximately (0.7159, 0.2841). One prediction gives P(X4=S)≈0.7159(0.8)+0.2841(0.4)=0.6864. Continuing from unrounded values gives sunny probabilities 0.6745, 0.6698, 0.6679, and 0.6672.

These approach 2/3. The chain gradually loses its dependence on the latest belief. Mixing time specifies how many steps are needed to come within a chosen distance of equilibrium from every starting state. A forecast close to equilibrium still retains a small influence from current evidence; it is not an exact reset.

Prediction need not increase uncertainty at every step. From (0.5, 0.5), this weather chain predicts (0.6, 0.4), a more concentrated distribution. Convergence concerns loss of dependence on the starting belief, not a rule that forecasts must become uniform.

Forecast an observation

An output forecast averages the sensor likelihood over predicted states:

P(Et+1=e∣e1:t)=∑jP(e∣j)fˉt+1(j).

For High on day 4, use the day-4 state prediction, not the day-3 filter: 0.6864(0.8)+0.3136(0.3)≈0.6432. The sunny probability and High-output probability differ because both weather states can produce High output.

Retain the totals from filtering

Before each update normalizes, its total is the probability of that observation given earlier ones. Call it ct=P(et∣e1:t−1). The chain rule gives

P(e1:t)=∏i=1tci.

For Low, Low, High, the totals are approximately 0.45, 0.4556, and 0.5429. Their product, computed before rounding, is 0.1113. This is a sum over every hidden path compatible with the evidence. The best path alone contributes 0.04704, only part of the total.

An unnormalized forward pass gives the same likelihood by summing its final entries. A normalized pass is more stable, provided the totals are kept. In long sequences, store log⁡P(e1:t)=∑ilog⁡ci instead of multiplying tiny values. Here the natural log is about −2.196.

Compare models on matching evidence

A likelihood measures how well one model accounts for a particular observation sequence. To compare candidate word HMMs on the same recording, score that recording under each model and combine with word priors when finding posterior word probabilities. Longer sequences usually have smaller raw likelihoods, so a smaller number from a longer recording alone does not show a worse model.

Key Takeaways

  • Future-state forecasts apply transitions without invented observations.
  • Observation forecasts average sensor likelihoods over predicted states.
  • Evidence likelihood is the product of the update totals.
  • Likelihood sums hidden paths; a Viterbi score keeps only the best one.
  • Log-likelihood adds log totals to avoid underflow.

3.3 Revising the past with forward–backward

A later observation can change what you believe about an earlier state. Smoothing estimates P(Xk∣e1:t) for k<t. It is useful when reconstructing a recorded trajectory or when an application can wait briefly before reporting a past estimate.

Divide the evidence at the target time

Filtering has already summarized evidence up to time k as fk(x)=P(Xk=x∣e1:k). A backward message summarizes the remaining observations as a likelihood, bk(x)=P(ek+1:t∣Xk=x). Combine them state by state:

P(Xk=x∣e1:t)∝fk(x)bk(x).

Normalize the products across states. The later evidence is weighted according to how plausible it would be from each candidate state at time k.

Pass the future likelihood backward

At the last time, there are no later observations, so bt(x)=1 for every state. Moving back one step gives

bk(i)=∑jTijP(ek+1∣j)bk+1(j).

For each possible successor, multiply the chance of moving there, the likelihood of its observation, and the remaining future likelihood. Then add over successors. A backward message is a likelihood function over possible starting states, not a state distribution; its entries need not add to 1.

Smooth day 2 in the solar example

The observations are Low, Low, High. After the two Low readings, the filtered day-2 belief is approximately (0.2146, 0.7854). For the final High reading, the backward likelihood from a sunny day 2 is 0.8(0.8)+0.2(0.3)=0.70. From a cloudy day 2 it is 0.4(0.8)+0.6(0.3)=0.50.

Multiply: the products are approximately 0.2146(0.70)=0.1502 and 0.7854(0.50)=0.3927. Normalize their unrounded values to obtain a day-2 sunny probability of 0.2767. High on day 3 makes a sunny day 2 more plausible than the original filtered probability 0.2146 did.

Continue to day 1

The backward likelihood from Sunny on day 1 is 0.8(0.2)(0.70)+0.2(0.7)(0.50)=0.182. From Cloudy it is 0.4(0.2)(0.70)+0.6(0.7)(0.50)=0.266. Combine with f1=(2/9,7/9) and normalize. The smoothed sunny probability is approximately 0.1635, down from 0.2222: the full future includes another Low as well as the final High.

Later evidence need not move every past estimate in the same direction. At the final time, smoothing equals filtering because no later evidence exists.

Organize the computation

The forward–backward algorithm first stores all forward beliefs, then computes backward messages and normalized products. For t steps and S states, dense computation costs O(S2t) and stores O(St) values. Fixed-lag smoothing reports the state a fixed number of steps behind the present, trading delay for more evidence.

Reversing the list of observations and running an ordinary filter is a different calculation. The backward recursion uses the original forward transitions and future likelihoods; it does not introduce a new initial prior at the recording's end. Smoothed state probabilities also supply expected counts for Baum–Welch learning.

Key Takeaways

  • Smoothing uses evidence from before and after the target time.
  • Multiply the forward belief by the future-evidence likelihood, then normalize.
  • The last backward message is all ones, not a uniform probability distribution.
  • Backward recursion sums successor contributions using the original transition model.
  • Fixed-lag smoothing trades reporting delay for later evidence.

3.4 Finding one best path

Sometimes the desired answer is one complete explanation of the observations. Viterbi decoding finds the most likely hidden-state sequence. It accounts for transitions between states, which separate most-likely choices at individual times can ignore.

Change the objective

The target is arg⁡max⁡x1:tP(x1:t∣e1:t). Every candidate has the same evidence denominator, so maximizing the joint score P(x1:t,e1:t) selects the same path. This score differs from a final-state posterior, which adds every path ending in that state.

With solar observations High, Low, the most likely individual states after smoothing are Sunny on day 1 and Cloudy on day 2. Yet Sunny, Sunny is the most likely complete path: its posterior is about 0.3282, compared with 0.2872 for Sunny, Cloudy. With forbidden transitions, individually plausible states can even make an impossible path.

Keep the best prefix for each ending state

Let mt(j) be the best joint path-and-evidence score ending in state j. Initialize m1(j)=P(X1=j)P(e1∣j). Then use

mt+1(j)=P(et+1∣j)max⁡i[mt(i)Tij].

Save the maximizing predecessor as a backpointer. Paths ending in the same state have the same possible future continuations, so a lower-scoring prefix can be discarded. The forward algorithm adds competing prefixes; Viterbi selects their maximum.

Fill the trellis for Low, Low, High

The initial scores are (0.10, 0.35). On day 2, the Sunny candidates before emission are 0.10(0.8)=0.08 and 0.35(0.4)=0.14. Keep the second and multiply by 0.2 to get 0.028, pointing to Cloudy. For Cloudy, compare 0.02 with 0.21; multiplying the larger by 0.7 gives 0.147, also pointing to Cloudy.

On day 3, Sunny compares 0.028(0.8)=0.0224 with 0.147(0.4)=0.0588. Multiplying the larger by the High likelihood 0.8 gives 0.04704. Cloudy compares 0.0056 with 0.0882; multiplying the larger by 0.3 gives 0.02646. Both final pointers lead to Cloudy on day 2.

Backtrack from the end

The largest final score is 0.04704 at Sunny. Follow its pointer to Cloudy on day 2, then that pointer to Cloudy on day 1. Reverse this backward traversal to obtain Cloudy, Cloudy, Sunny. Dividing by the evidence likelihood 0.1113 gives its posterior, approximately 0.4226.

Choosing the largest score separately at every column would discard the stored predecessor relationships. The final score vector also cannot be normalized into a filtering belief: it retains just one path per state, not their sums.

Use logarithms for long sequences

Products can underflow. Store log scores instead:

ℓt+1(j)=log⁡P(et+1∣j)+max⁡i[ℓt(i)+log⁡Tij].

Logarithms preserve ordering, so the path and pointers stay unchanged. Zero probabilities become negative infinity. Equivalently, negative log scores turn decoding into a minimum-cost path through a time-layered graph, or trellis. Dense Viterbi costs O(S2t) time and stores O(St) pointers. If paths tie for the largest score, each is a valid most likely explanation.

Key Takeaways

  • Viterbi maximizes one complete path, while filtering sums paths.
  • Keep the best prefix per ending state and save its predecessor.
  • Reconstruct the answer by backtracking from the largest final score.
  • Per-time marginal modes can differ from the best complete path.
  • Log-space computation preserves the maximizing path and avoids underflow.
4

Filtering with sampled states

A sampled population can carry a belief when a full table is too large. Follow how particles move, gain weights from a reading, and produce a new population through resampling. Each operation has a clear counterpart in exact filtering, along with its own source of approximation. Population size, lost regions, and the shape of the belief then help decide whether sampling or an exact representation is the better fit.

4.1 Sampling a changing belief

A probability table becomes difficult to store when the state space is huge. Continuous beliefs also lack a finite table in general. A particle filter represents a belief using sampled states, allowing computation to focus on a manageable population of possibilities.

Represent probability with particles

Each particle is one complete state, not a separate physical object. After resampling, all particles have equal weight, and a state's estimated probability is the fraction occupying it. Ten particles split seven Sunny and three Cloudy represent the belief (0.7, 0.3).

Draw initial particles from P(X1). A prior of (0.5, 0.5) gives expected equal counts but does not force every random sample to split equally. Under our time convention, weight these initial particles by the first observation and resample before any transition.

Elapse time by sampling transitions

For each later step, move each particle independently using the transition row for its current state. With weather rows (0.8, 0.2) and (0.4, 0.6), seven Sunny and three Cloudy particles have an expected sunny count of 7(0.8)+3(0.4)=6.8 after moving.

One realized sample might contain six Sunny and four Cloudy particles. An expected count can be fractional; a realized particle count must be an integer. Keeping exactly 6.8 particles would not be a sampling algorithm.

Weight by the reading

Suppose the new solar output is Low. Each Sunny particle gets likelihood 0.2; each Cloudy particle gets 0.7. The six Sunny particles have total weight 6(0.2)=1.2, and the four Cloudy particles have 4(0.7)=2.8. Out of total weight 4.0, Sunny has weighted probability 0.3 and Cloudy 0.7.

Counts matter as well as per-particle weights. Normalizing only 0.2 and 0.7 would ignore how much predicted probability each group represented. Weighting reuses the same Bayes update as exact filtering on this sampled prediction.

Resample a fresh population

Draw ten particles with replacement, each old particle selected in proportion to its weight. Each new draw is Sunny with probability 0.3 and Cloudy with probability 0.7. The expected sunny count is three, though a run may give two, four, or another count. Multiple copies are allowed; they represent probability mass.

Reset the resulting particles to equal weights. Evidence has already affected which particles were copied, so retaining the old likelihood weights would count it again. The next iteration moves this new population before processing the next observation.

Compare with the exact update

Exact filtering from (0.7, 0.3) predicts (0.68, 0.32). Low then gives weights (0.136, 0.224), so the exact sunny posterior is 0.136/0.36≈0.3778. The particle run's weighted result was 0.3 because its random motion produced only six Sunny particles. Resampling introduces another source of variation.

The loop is therefore initialization, first-observation weighting and resampling, followed by repeated motion, weighting, and resampling. Before resampling, read weighted fractions; afterward, read counts. A step costs roughly O(N) for N particles when state sampling and weighting have fixed cost. For two weather states, exact filtering is simpler. Particle methods become useful when a large or continuous state lacks an affordable compact exact filter.

Key Takeaways

  • A particle is one sampled state; a population represents uncertainty.
  • Initialize at X₁ and process its observation before moving.
  • Later iterations sample motion, weight by evidence, and resample.
  • Resampling is with replacement and produces equal-weight particles.
  • Particle estimates vary because motion and resampling are random.
  • Work scales with particle count when sampling and weighting costs stay fixed.

4.2 Accuracy, lost hypotheses, and filter choice

A particle estimate is random, so its quality depends on both population size and where the particles survive. More particles improve the approximation, but a large population can still be ineffective when nearly all its useful information sits in a few samples.

Understand the accuracy scale

For an independent-sample estimate of a probability p, the standard error is approximately p(1−p)/N. With p=0.3, this is about 0.046 for 100 samples and 0.0046 for 10,000. Particle-filter error often has the same rough 1/N scale, though resampled particles are dependent and model difficulty matters.

Quadrupling the population roughly halves error; doubling it does not. For a fixed observation history, increasing the number of particles makes a consistent particle filter approach the exact belief. This does not make one finite run exact or remove errors in the underlying model. Fix a random seed for reproducible comparisons, or compare results across several runs.

Distinguish two failures
FailureWhat goes wrongWhat helps
Weight degeneracyA few particles carry nearly all the weight.Resampling concentrates effort on likely states.
Sample impoverishmentMany surviving particles are copies and plausible regions disappear.More particles or ways to introduce new states can preserve diversity.

Without resampling, multiplying likelihoods over many steps can leave almost every particle with negligible weight. Resampling replaces that waste with copies of useful states. But it can also erase an alternative location that temporarily fits less well.

Resampling alone cannot recreate an absent region. Recovery depends on motion samples reaching it or another mechanism introducing particles there. If transitions make that region nearly inaccessible, recovery may be slow. Adding small random perturbations or replacing a small fraction with fresh particles can help, but these choices must respect the state representation and intended approximation.

Handle zero total weight

If every particle receives weight zero, resampling probabilities are undefined. The observation may be possible elsewhere in the model even though the sampled population missed those states. Reinitialize from a suitable distribution, such as the prior or a uniform distribution over valid states, and check the sensor model. A nonzero outlier component can reduce these failures. If the model itself rules out the observation everywhere, more particles alone cannot fix it.

Choose a representation that fits the model

Exact forward filtering suits small discrete state spaces. A Kalman filter is exact when the prior is Gaussian and the transition and sensor models are linear with Gaussian noise; a mean and covariance then describe the belief. A particle filter accommodates nonlinear models and beliefs with separated peaks.

A single Gaussian cannot faithfully represent a robot that is likely in either of two distant corridors but unlikely between them. Particle clusters can retain both alternatives. For a linear-Gaussian tracking model, the Kalman representation usually avoids unnecessary sampling noise.

In a DBN, each particle holds a full assignment to all state variables. Sample next-step variables in topological order from their parent-conditioned models. Factoring reduces work per sample compared with enumerating every joint state, although high-dimensional beliefs may still require many particles to cover their important regions.

Key Takeaways

  • Error often shrinks roughly with 1/√N, so halving it needs about four times the particles.
  • Resampling counters concentrated weights but can reduce state diversity.
  • A lost region needs motion or new-particle generation to return.
  • Zero total weight makes resampling undefined and calls for recovery.
  • Linear-Gaussian models with Gaussian priors have exact Kalman filters.
  • Particle filters can represent separate peaks and factored state assignments.
5

Tracking and sequence recognition

A robot locating itself and a recognizer labeling speech face the same underlying problem: observations leave several hidden explanations plausible. The models differ in what counts as a state, a transition, and a reading. Corridor localization shows how repeated motion and sensing preserve or resolve alternative positions, while speech and grammatical tagging show how sequence probabilities connect labels across time.

5.1 Tracking position while keeping alternatives

Tracking combines uncertain motion with noisy measurements. The hidden state may contain position and velocity; observations may come from GPS, radar, or a camera. Filtering carries a distribution of plausible locations from one reading to the next.

Localize in a five-cell corridor

A robot occupies one of five cells, with doors at cells 1 and 4. Its sensor reports a door with probability 0.9 at a door and 0.2 elsewhere. Start uniformly, with probability 0.2 per cell. A door report gives weights (0.18, 0.04, 0.04, 0.18, 0.04), totaling 0.48.

The updated belief is (0.375,  1/12,  1/12,  0.375,  1/12). Both door cells remain plausible. Selecting just one peak would throw away the symmetry the sensor has not resolved.

Move the whole belief

The robot tries to move one cell right. It succeeds with probability 0.8 and stays with probability 0.2; from cell 5 it stays with certainty at the wall. Every cell receives contributions from all starting cells that can reach it.

Cell 1 gets 0.375(0.2)=0.075. Cell 2 gets 0.375(0.8)+(1/12)(0.2)≈0.3167. Cells 3 and 4 get approximately 0.0833 and 0.1417. Cell 5 gets (0.375)(0.8)+1/12≈0.3833: both arrivals from cell 4 and all existing cell-5 mass remain there.

The prediction is approximately (0.0750, 0.3167, 0.0833, 0.1417, 0.3833). Handling the boundary as another ordinary 0.8 move would lose probability beyond the modeled corridor.

Observe no door

The no-door likelihood is 0.1 in cells 1 and 4 and 0.8 elsewhere. Multiplying the unrounded prediction gives total weight approximately 0.6483. Normalizing produces (0.0116, 0.3907, 0.1028, 0.0219, 0.4730).

The likely locations are now cells 2 and 5, just after the two doors. The belief remains multimodal, with separate peaks. One sensor reading is evidence, not a true-position measurement; keeping alternatives gives later motion and readings a chance to distinguish them.

Extend to realistic robots

In Monte Carlo localization, a particle is a pose: position in meters and heading. Move each pose using commanded motion plus noise, then weight it by agreement between observed ranges and ranges predicted from a known map. A concentrated initial population tracks a known starting location; a broad one supports global localization.

If the map is also unknown, include it in the hidden state. Simultaneous localization and mapping, or SLAM, estimates map and pose together. With multiple objects, another issue is data association: deciding which detection belongs to which object. Different assignments produce different trajectory hypotheses.

Vehicle tracking can combine a motion prediction with GPS readings. At 15 m/s with one-second steps, the expected motion is about 15 m between readings. A suitable Kalman model combines uncertain motion and measurement to reduce the effect of noisy readings. A transition model with no allowance for real motion variation can exclude the true trajectory, even when its arithmetic is correct.

Key Takeaways

  • Tracking models hidden motion and noisy readings separately.
  • Localizing keeps all plausible positions until evidence separates them.
  • Boundary transitions must conserve probability within the state space.
  • Monte Carlo localization represents robot poses with particles.
  • SLAM estimates both pose and map; data association links readings to objects.

5.2 Speech and other sequence labels

Sequence models can infer labels as well as physical states. A speech recognizer connects a changing sound signal to possible words. A part-of-speech tagger connects observed words to hidden grammatical labels. Both must score choices in context across time.

Combine sound fit and language probability

Speech recognition seeks the word sequence with greatest posterior probability:

arg⁡max⁡wP(w∣s)=arg⁡max⁡wP(s∣w)P(w).

The acoustic model P(s∣w) scores how well words explain the sound; the language model P(w) scores their prior plausibility. The shared denominator P(s) does not affect the ranking. An acoustic likelihood is not itself a posterior probability of words.

For illustrative scores, compare “recognize speech” with “wreck a nice beach.” Acoustic likelihoods are 0.0004 and 0.0005; language probabilities are 0.00002 and 0.000001. The first product is 8×10−9 and the second 5×10−10. Language context makes the first phrase win despite its slightly lower acoustic likelihood.

Turn audio into a time sequence

A common setup uses overlapping 25 ms frames beginning every 10 ms, yielding about 100 feature vectors per second. The vectors are observations. Hidden states represent parts of speech sounds, or phones, often with beginning, middle, and end states. A pronunciation dictionary connects words to phones.

Self-loops allow a sound state to occupy multiple frames. Without duration flexibility, changing speaking speed would require a fixed and often unsuitable alignment between frames and sound states. Different state paths express different alignments of the same observed recording.

Represent short language context

A bigram model approximates a word sequence with P(w1)∏i=2nP(wi∣wi−1). A trigram uses the previous two words. Estimate these conditional probabilities from text counts. The Markov assumption here is a practical approximation: long-range grammatical and semantic relationships can extend beyond one or two preceding words.

Viterbi can find the best state path through linked phone and word models. For a large vocabulary, beam search discards less promising partial paths to reduce work. Once discarded, a path cannot win later, so a narrow beam can miss the best full path. Also, the best single state path for a word sequence differs in objective from summing all its possible alignments.

Use the same structure for tags

In part-of-speech tagging, states are tags and observations are words. Transitions score P(tagi∣tagi−1); emissions score P(wordi∣tagi). In “They can fish,” “can” may describe ability or putting fish into cans. The tag path must account for both word likelihoods and transitions between tags.

Place HMMs in speech practice

Large-vocabulary systems from the 1980s to the early 2010s commonly combined HMMs with Gaussian mixture acoustic models. Around 2010–2012, neural acoustic models became prominent in hybrid DNN–HMM systems. Modern end-to-end neural systems can map audio to text without an explicit HMM. The shared ideas of uncertain alignment, sequence scoring, and dynamic programming remain useful, and HMMs also appear in applications such as gene finding in DNA.

Key Takeaways

  • Word recognition combines acoustic likelihood with a language prior.
  • Frames provide observations; phone-state self-loops model variable duration.
  • Bigram and trigram models approximate language with short histories.
  • Viterbi finds a best path; beam pruning can sacrifice that guarantee.
  • Part-of-speech tagging treats tags as hidden states and words as evidence.
  • Modern speech systems include hybrid and end-to-end neural approaches.

Hidden Markov Models examples

5 Walkthroughs

1

Predict weather and test equilibrium

13 steps
Read transitions, compute paths and forecasts, and distinguish stationary balance from convergence.
  1. 1
    IntroductionFrom daily changes to long-run balance

    A weather forecast begins with what you know now and a rule for what can happen next. That is the Markov property: the current state is enough to predict the next one. The same rule can score a particular run of days or predict a whole distribution.

    We will use Sunny and Cloudy states to follow both calculations. Then we will ask when repeated forecasts settle into a balance, a stationary distribution, and why a balanced distribution does not mean the weather has stopped changing.

  2. 2
    ExplanationRead the current state first

    The Markov property says that knowing the current state makes earlier history unnecessary for predicting the next one. It does not make neighboring days independent.

    A complete chain needs a starting distribution and transitions. If those transitions stay fixed, the chain is time-homogeneous. Its state distribution can still change: the fixed rule describes movement, not a fixed mix of states.

  3. 3
    ExampleTurn the weather rule into rows

    Use the order Sunny, Cloudy for both rows and columns:

    T=(0.80.20.40.6).

    The Sunny row says “stay sunny with probability 0.8; switch cloudy with probability 0.2.” The Cloudy row gives 0.4 and 0.6. Each row describes every destination from one starting state and sums to 1. A column collects arrivals from different starting states, so it need not sum to 1.

  4. 4
    ExampleFollow one weather path

    Suppose day 1 is certainly Sunny. For Sunny, Sunny, Cloudy, Cloudy, multiply the probability of each move in order:

    1(0.8)=0.8,0.8(0.2)=0.16,0.16(0.6)=0.096.

    This is the probability of that complete path. The two Cloudy days contribute different factors because one is a switch from Sunny and the other is a continuation from Cloudy.

  5. 5
    ChallengeCarry the right history

    A process depends on the last two weather values. Its combined state today is (Sunny, Cloudy). What must be the first component of the next combined state, and why?

    ---reveal---

    It must be Cloudy. The next pair stores (today, tomorrow), so its first component copies the current pair’s second component. State augmentation stores needed history while keeping a first-order transition rule.

  6. 6
    ExampleCollect every way to become sunny

    Starting certainly Sunny gives day-2 belief (0.8, 0.2). Day 3 can become Sunny from either state:

    0.8(0.8)=0.64,0.2(0.4)=0.08.

    Add these contributions to get 0.72. Cloudy receives 0.8(0.2)+0.2(0.6)=0.28. Thus the distribution is (0.72, 0.28). Multiplying along one path and adding across alternative paths are different operations.

  7. 7
    TipKeep the vector on the left

    With our transition convention, a row belief advances as pt+1=ptT. Repeating gives pt+k=ptTk.

    Check that all entries are nonnegative and total 1. Putting a Sunny point-mass column on the right of this matrix gives (0.8, 0.4), which totals 1.2. Those entries describe two different starting states’ chances of becoming Sunny, not one belief’s distribution of destinations.

  8. 8
    ChallengePredict one more day

    The day-3 belief is (0.72, 0.28). With Sunny and Cloudy transition rows (0.8, 0.2) and (0.4, 0.6), what is the sunny probability on day 4?

    ---reveal---

    0.72(0.8)+0.28(0.4)=0.576+0.112=0.688.

    The cloudy probability is 0.312. Both current states contribute to tomorrow. A single simulated run would instead occupy just one state on day 4; many runs estimate this distribution.

  9. 9
    ExampleFind the distribution that stays balanced

    At equilibrium, probability leaving Sunny for Cloudy matches probability returning:

    0.2πS=0.4πC,πS+πC=1.

    The flow equation gives πS=2πC. Therefore 3πC=1 and π=(2/3,1/3). Applying the matrix to this vector returns the same vector. Individual days still change; only the distribution is unchanged by the transition.

  10. 10
    Key InsightExistence is only the first question

    Every finite chain has a stationary distribution. Irreducibility, meaning all states can reach each other, ensures uniqueness. In a finite irreducible chain, stationary probabilities also describe long-run time fractions.

    Add aperiodicity to guarantee convergence from every start. Our weather matrix has every entry positive, satisfying both conditions. A chain with fixed transition rows alone need not converge.

  11. 11
    ChallengeA balanced vector without convergence

    Two states always swap, and the chain starts certainly in the first. Does its distribution converge to the stationary vector (0.5, 0.5)?

    ---reveal---

    No. Its distributions alternate (1, 0), (0, 1), (1, 0), and continue forever. Each state still occupies half the steps in a long run. This separates convergence of a time-specific distribution from the limiting fractions along a trajectory.

  12. 12
    ChallengeConnect prediction and equilibrium

    A two-state chain starts at (0.3, 0.7), and both states are absorbing. What will repeated prediction do, and is the unchanged vector the only stationary distribution?

    ---reveal---

    Prediction always returns (0.3, 0.7), because each state keeps its mass. Every mixture is stationary, including both point masses. This start has a limit, but the chain has no unique stationary distribution shared across all starts.

  13. 13
    RecapChoose the quantity before calculating

    For a path, multiply its initial probability and transitions. For a distribution at one time, add all incoming contributions through matrix prediction.

    For long-run behavior, solve the stationary equations and then check reachability and periodicity. The same chain can have a stationary vector, oscillating predictions, and well-defined time fractions. Keeping those questions separate gives each number a clear interpretation.

2

Build a model for hidden weather

10 steps
Construct the HMM, score a joint explanation, and make practical choices about states and parameters.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionInfer what a sensor cannot show directly
  2. 2
    ExplanationSeparate motion from observation
  3. 3
    ExampleFill the solar sensor model
  4. 4
    ExampleScore states and readings together
  5. 5
    ChallengeDo observations become independent?
  6. 6
    ExplanationChoose what the state remembers
  7. 7
    ExampleLearn a row from labeled transitions
  8. 8
    ChallengeCount choices after normalization
  9. 9
    ChallengeA surprising but uninformative reading
  10. 10
    RecapMatch the model to the question
3

Follow the solar evidence through time

20 steps
Filter, forecast, smooth, and decode the same three readings, with each calculation worked in order.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionOne recording, several inference questions
  2. 2
    ExampleProcess the first Low
  3. 3
    ExampleMove before the second Low
  4. 4
    ExampleLet High shift the odds
  5. 5
    ChallengeDiagnose a missing operation
  6. 6
    ExampleForecast the next state and output
  7. 7
    Key InsightKeep the scales you divided out
  8. 8
    ChallengeForecast without new evidence
  9. 9
    ExplanationSend later evidence backward
  10. 10
    ExampleRevise day 2
  11. 11
    ExampleContinue back to day 1
  12. 12
    ChallengeUse the right backward quantity
  13. 13
    ExplanationSwitch from all paths to one path
  14. 14
    ExampleFill the second Viterbi column
  15. 15
    ExampleChoose the final winner
  16. 16
    TipAvoid multiplying tiny scores
  17. 17
    ChallengeCompare path and state estimates
  18. 18
    ChallengeGive the winning path a posterior
  19. 19
    ConnectionChoose latency and memory deliberately
  20. 20
    RecapRead each result by its objective
4

Run and diagnose a particle filter

12 steps
Follow a sampled update, compare it with the exact result, and recognize common failures.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionReplace a large table with samples
  2. 2
    ExplanationOne population, one belief
  3. 3
    ExampleSample the motion step
  4. 4
    ExampleWeight the sampled prediction
  5. 5
    ExampleDraw replacements with equal weights
  6. 6
    ChallengeCompare the exact calculation
  7. 7
    ExplanationKnow what more particles buy
  8. 8
    Key InsightWeights and diversity are different
  9. 9
    ChallengeHandle a zero weight total
  10. 10
    ConnectionChoose a compact exact belief when available
  11. 11
    ChallengePreserve a location alternative
  12. 12
    RecapCheck both count and coverage
5

Apply temporal reasoning to robots and speech

13 steps
Work through corridor localization, then map the same ideas to speech recognition and grammatical tags.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionLocate a robot and label a sequence
  2. 2
    ExampleStart with two doors
  3. 3
    ExampleMove probability to the right
  4. 4
    ExampleLet the next reading favor cells past doors
  5. 5
    ChallengeAvoid committing before the sensor can decide
  6. 6
    ConnectionGive particles a pose and a map
  7. 7
    ExplanationTurn sound into evidence
  8. 8
    ExampleCombine acoustic fit with language context
  9. 9
    ExplanationConnect word and sound models
  10. 10
    ChallengeIdentify a tagger’s components
  11. 11
    ConnectionPlace the methods in modern speech systems
  12. 12
    ChallengeChoose what the application needs
  13. 13
    RecapName the hidden quantity and the evidence

Hidden Markov Models practice questions

40 Practice Questions in 4 sets

Set 1: Particles and localization10 Practice Questions

Question 1 of 10

After equal-weight resampling, 27 of 90 particles occupy region R. What probability does this population assign to R?
  1. 0.27
  2. 0.30
  3. 0.70
  4. 0.90
Show answerHide answer
Answer: B
Equal-weight particles represent probability by their relative counts: 27/90=0.30. The value 0.27 would treat the population as if it contained 100 particles. Before equal-weight resampling, raw counts alone would not account for differing particle weights.

Question 2 of 10

An elapsed population has 8 particles in A and 12 in B. A reading has likelihood 0.6 in A and 0.2 in B. What is the expected number of A particles after resampling 20 particles?
  1. 13.3333
  2. 8.0000
  3. 12.0000
  4. 15.0000
Show answerHide answer
Answer: A
Group weights are 8(0.6)=4.8 and 12(0.2)=2.4, giving A probability 4.8/7.2=2/3. The expected count is 20(2/3)≈13.3333. Using 15 normalizes only the likelihoods and ignores the unequal starting group sizes.

Question 3 of 10

A particle population contains 30 A and 10 B states. Transition probabilities to A are 0.7 from A and 0.2 from B. What is the expected A count after one motion step?
  1. 21
  2. 28
  3. 25
  4. 23
Show answerHide answer
Answer: D
Expected arrivals from A are 30(0.7)=21 and from B are 10(0.2)=2, totaling 23. Counting only 21 omits B-to-A moves. This is an expected count over random motion samples, so one actual run need not contain exactly 23 A particles.

Question 4 of 10

A particle estimate has typical error about 0.08 with 400 particles. Under the usual inverse-square-root scaling, about how many particles are needed for error 0.02?
  1. 1,600
  2. 800
  3. 3,200
  4. 6,400
Show answerHide answer
Answer: D
The desired error is one quarter as large. Under 1/N scaling, particle count must grow by 42=16, from 400 to 6,400. Using 1,600 only quadruples the count and would roughly halve the error to 0.04, not quarter it.

Question 5 of 10

A robot model has two pose regions with no transitions between them. A particle run loses every particle in the true region during resampling, but that region has positive model probability. Later readings strongly favor it. What can restore support there?
  1. Introduce fresh particles into the absent region.
  2. Resample the existing particles many more times.
  3. Increase the weights of the remaining region equally.
  4. Wait for the ordinary motion step to cross regions.
Show answerHide answer
Answer: A
Neither copying existing particles nor motion confined to the wrong region can create support in the missing region. A recovery mechanism must generate particles there, for example through reinitialization. Strong readings reveal the mismatch but cannot give weight to a state that has no particle.

Question 6 of 10

A small discrete model gives a new reading positive likelihood only in state C. A particle population contains only A and B, so every weight is zero. What do exact filtering and the particle update require?
  1. Both updates must fail because the reading has zero likelihood in A and B.
  2. Particles can normalize zero weights; exact filtering must reinitialize.
  3. Exact filtering can update if predicted C mass is positive; particles need recovery.
  4. Both updates become uniform because the evidence rules out their likely states.
Show answerHide answer
Answer: C
Exact filtering can retain positive predicted mass at C and normalize its contribution. The particle approximation has no sample there, so its weight total is zero and needs a recovery distribution. Zero particle support is a sampling failure here, not evidence that the full model makes the reading impossible.

Question 7 of 10

A robot is equally likely in cells 1, 2, 3, and 4. A marker is present in cells 1 and 3. A detector reports a marker with probability 0.8 there and 0.1 elsewhere. After a marker report, what is the probability of cell 3?
  1. 0.8000
  2. 0.4444
  3. 0.5000
  4. 0.2000
Show answerHide answer
Answer: B
The four weights are 0.20, 0.025, 0.20, and 0.025, totaling 0.45. Cell 3 therefore has probability 0.20/0.45≈0.4444. Assigning 0.5 ignores false positives in cells without markers; those cells retain a small share of the belief.

Question 8 of 10

A robot starts uniformly in cells 1–3. It moves one cell right with probability 0.75 and stays otherwise; at cell 3 it stays with certainty. A reading has likelihood 0.8 only in cell 2 and 0.2 elsewhere. What is the posterior probability of cell 3?
  1. 0.5833
  2. 0.3333
  3. 0.2917
  4. 0.1667
Show answerHide answer
Answer: C
The motion prediction is (1/12,1/3,7/12). Sensor weighting gives (1/60,4/15,7/60), totaling 2/5, so cell 3 has posterior 7/24≈0.2917. Reporting 0.5833 stops at the motion prediction and ignores the evidence favoring cell 2.

Question 9 of 10

A tracker has a Gaussian prior, a linear motion model, and linear observations with Gaussian noise. Its particle approximation is noisy. A colleague proposes representing the exact belief with a mean and covariance. How should the proposal be judged?
  1. Valid: these assumptions keep the posterior Gaussian.
  2. Invalid: continuous states always require sampled beliefs.
  3. Valid only after discretizing the position into cells.
  4. Invalid unless every measurement is free of noise.
Show answerHide answer
Answer: A
These are the linear-Gaussian conditions for exact Kalman filtering, so a mean and covariance suffice. Continuous state alone does not force particle approximation. Discretizing first would replace the continuous model with a different finite one and is unnecessary here.

Question 10 of 10

A filter’s weights are evenly spread, but almost every particle is a copy of one of two surviving poses. What problem does this describe?
  1. Weight degeneracy
  2. Sample impoverishment
  3. Floating-point underflow
  4. An invalid sensor row
Show answerHide answer
Answer: B
The problem is lost diversity, or sample impoverishment: many equal-weight particles repeat very few states. Weight degeneracy instead means a few particles hold most of the total weight. Equalizing weights after resampling does not guarantee broad coverage of plausible poses.
Set 2: Combined reasoning and model diagnosis10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

In an HMM part-of-speech tagger, the observed sentence is “Small birds fly.” What are the hidden states?
  1. The grammatical tags of the words.
  2. The observed words of the sentence.
  3. The transition probabilities between tags.
  4. The measured durations of audio frames.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

Two candidate transcripts have acoustic likelihoods 0.006 and 0.004 and language priors 0.01 and 0.03, respectively. Which transcript has the larger posterior score, and by what factor?
  1. The first, by a factor of 1.5.
  2. The second, by a factor of 3.
  3. The second, by a factor of 2.
  4. The first, by a factor of 2.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A labeled two-state training record has 8 transitions A → A and none A → B. After adding one pseudo-count per destination, a new run starts certainly at A and a reading at the next time has likelihoods (0.1, 0.9). What is the posterior probability of B?
  1. 0.0
  2. 0.1
  3. 0.9
  4. 0.5
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

From A a chain goes to absorbing B with probability 0.4 or absorbing C with probability 0.6. It has no other transitions out of A. Starting at A, what limit is reached, and is it the chain’s unique stationary distribution?
  1. (0, 0.4, 0.6); it is unique.
  2. (0, 0.4, 0.6); it is not unique.
  3. (0, 0.5, 0.5); it is not unique.
  4. No limit exists; the stationary distribution is unique.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A previous filtered belief is (0.8, 0.2). Transition rows are (0.5, 0.5) and (0.25, 0.75). A sensor reading is twice as likely in A as in B. What is the new A probability?
  1. 0.8889
  2. 0.6207
  3. 0.4500
  4. 0.6667
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A log-space Viterbi update must compare predecessor log scores −3.2 and −2.8 after including transition terms. The destination emission log likelihood is −0.5. What new score is stored?
  1. −3.7
  2. −6.5
  3. −2.3
  4. −3.3
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

Two candidate transcripts have equal priors. For a fixed recording, transcript A has two compatible alignment paths with joint acoustic scores 0.06 and 0.06. Transcript B has one with score 0.10. All other path scores are zero. How do transcript likelihood ranking and best-path ranking compare?
  1. Likelihood favors A; the best path favors B.
  2. Both likelihood and the best path favor B.
  3. Both likelihood and the best path favor A.
  4. Likelihood favors B; the best path favors A.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

Before a new audio frame, a beam decoder discards a partial path with score 0.04 and retains one with 0.05. What can be concluded about the final best path?
  1. The retained path must remain better at every later frame.
  2. The discarded path can return through later resampling.
  3. The discarded path could still have become the best.
  4. The final paths must have equal posterior probabilities.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A two-state chain has identical transition rows (0.3, 0.7). A signal has likelihoods (0.8, 0.2). Two agents have different current beliefs from different past readings. What signal probability will each predict one step ahead, and why?
  1. Both predict 0.50; forgetting the past makes the next state uniform.
  2. They may differ; a sensor update must always preserve past-belief differences.
  3. Both predict 0.38; the next-state distribution is independent of the current belief.
  4. Both predict 0.30; the signal probability equals the first state’s forecast.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A DBN has six Boolean next-state variables. Each has two Boolean parents and one probability of True for each parent assignment. How many transition probabilities are stored in those local tables?
  1. 24
  2. 64
  3. 48
  4. 4,096
Show answerHide answer

Save this lesson to see this answer.

Set 3: States, transitions, and observations10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

A service has states Idle and Busy. From Idle it remains Idle with probability 0.75. What is its row of transition probabilities in the order Idle, Busy?
  1. (0.75, 0.75)
  2. (0.25, 0.75)
  3. (0.75, 0.25)
  4. (0.25, 0.25)
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A device starts On with probability 0.6. Its transition rows for On, Off are (0.7, 0.3) and (0.2, 0.8). What is the probability of the path On, Off, Off?
  1. 0.240
  2. 0.144
  3. 0.336
  4. 0.036
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A machine is Active with probability 0.3 and Resting with probability 0.7. The transition rows in that order are (0.9, 0.1) and (0.4, 0.6). What is the probability it is Active one step later?
  1. 0.55
  2. 0.27
  3. 0.45
  4. 0.63
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A chain switches from A to B with probability 0.3 and from B to A with probability 0.2. What stationary probability does it assign to A?
  1. 0.6
  2. 0.5
  3. 0.2
  4. 0.4
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A chain moves deterministically A → B → C → A. It starts certainly at A. What are its limiting state distribution and long-run time fractions?
  1. Limiting distribution (1/3, 1/3, 1/3); the same time fractions.
  2. No limiting distribution; time fractions (1/3, 1/3, 1/3).
  3. No limiting distribution; time fractions depend on the start.
  4. Limiting distribution (1, 0, 0); time fractions (1/3, 1/3, 1/3).
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A second-order model has four possible original values. How many ordered-pair states are available when it is rewritten as first-order?
  1. 8
  2. 4
  3. 16
  4. 12
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A hidden device starts Ready with probability 0.4. It moves Ready → Faulty with probability 0.25. An alarm has likelihood 0.1 in Ready and 0.8 in Faulty. What is the joint probability of states Ready, Faulty and alarms at both times?
  1. 0.008
  2. 0.080
  3. 0.032
  4. 0.020
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

An unrestricted HMM has three hidden states and four possible observation values. How many free probability parameters does it have?
  1. 24
  2. 20
  3. 14
  4. 17
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A predicted belief is (0.65, 0.35). A reading has likelihood 0.02 in each state. What is the posterior belief?
  1. (0.50, 0.50)
  2. (0.013, 0.007)
  3. (0.02, 0.98)
  4. (0.65, 0.35)
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A mode is A with filtered probability 0.6. Transition rows for A, B are (0.7, 0.3) and (0.2, 0.8). A future signal has likelihood 0.9 in A and 0.1 in B. What is the signal probability two steps ahead?
  1. 0.46
  2. 0.50
  3. 0.58
  4. 0.45
Show answerHide answer

Save this lesson to see this answer.

Set 4: Filtering, smoothing, and decoding10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

An evidence sequence has likelihood 0.24. Its best hidden path has joint score 0.09. What is the posterior probability of that complete path?
  1. 0.090
  2. 0.240
  3. 0.625
  4. 0.375
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

For fixed observations, two-time state-path joint scores are AA: 0.24, AB: 0.27, BA: 0.28, BB: 0.01. What path is made by the two marginal modes, and what path is the Viterbi answer?
  1. Marginal modes B, A; Viterbi B, A.
  2. Marginal modes A, A; Viterbi B, A.
  3. Marginal modes A, A; Viterbi A, A.
  4. Marginal modes A, B; Viterbi B, A.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

An HMM has a prior directly on X₁ and its first observation is e₁. What should happen before the first normalization?
  1. Move the prior through T, then weight by e₁.
  2. Normalize the prior again without weighting.
  3. Weight the prior by a transition probability.
  4. Weight the prior by the likelihood of e₁.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A filter assigns probabilities (0.2, 0.8) to states A, B. Transition rows are (0.6, 0.4) and (0.1, 0.9). A new reading has likelihoods (0.75, 0.25). What is the updated probability of A?
  1. 0.4286
  2. 0.2000
  3. 0.1500
  4. 0.6000
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

Normalized filtering produces successive update totals 0.4, 0.3, and 0.5. What likelihood does the model assign to the complete observation sequence?
  1. 0.40
  2. 1.20
  3. 0.06
  4. 0.50
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

At a past time, the filtered belief is (0.4, 0.6) and the future-evidence likelihoods are (0.3, 0.8). What is the smoothed probability of the first state?
  1. 0.4
  2. 0.2
  3. 0.3
  4. 0.12
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A transition model for A, B has rows (0.6, 0.4) and (0.3, 0.7). Tomorrow’s observed reading has likelihoods (0.2, 0.9). Today’s filtered belief is (0.5, 0.5). What is today’s smoothed probability of A after tomorrow’s reading?
  1. 0.1538
  2. 0.4800
  3. 0.4103
  4. 0.4500
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

At the final Viterbi column, the largest score ends in A. Its pointer leads to B, whose previous pointer leads to A at time 1. What three-state path was decoded?
  1. A, B, A
  2. B, A, A
  3. A, A, B
  4. B, B, A
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

An HMM starts equally in A and B. Its transition rows are (0.9, 0.1) and (0.4, 0.6). Observations r then s have likelihoods r: (0.6, 0.4), s: (0.2, 0.8). What is the best two-state path and its joint score?
  1. A, A; 0.054
  2. B, B; 0.096
  3. A, B; 0.024
  4. B, A; 0.016
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A forward filter keeps normalized beliefs but discards each pre-normalization total. What can it still report directly, and what information has been lost?
  1. Current state belief; the scale needed for evidence likelihood.
  2. Evidence likelihood; the relative current state probabilities.
  3. Best state path; the posterior of its final state.
  4. Backward message; the likelihood of the first observation.
Show answerHide answer

Save this lesson to see this answer.

Stuck on your own question? Homework Help

Key Terms

66 Key Terms, each with its definition

A

Absorbing state
An absorbing state has probability 1 of remaining in itself at the next step, so a run cannot leave after entering it.
With two absorbing states, the starting mixture persists instead of approaching one shared mixture.
Acoustic model
An acoustic model scores the likelihood of observed sound features under a proposed speech-state or word explanation.
An acoustic model can favor a phrase that sounds similar even when its language prior is small.
Aperiodicity
Aperiodicity means that a state’s possible return lengths have greatest common divisor 1, preventing a fixed longer cycle.
A reachable self-loop makes a finite irreducible chain aperiodic, allowing convergence from any start.

B

Backpointer
A backpointer stores the predecessor state that gives the best path into a particular state at a particular time.
Following backpointers from the final winner recovers the complete decoded weather path.
Backward message
A backward message gives the likelihood of all later observations for each candidate hidden state at a chosen earlier time.
A day-2 backward message such as (0.70, 0.50) scores a later High solar reading from each of two possible weather states.
Balance equation
A balance equation equates a stationary state probability with the total incoming probability from all states after one move.
In a Sunny–Cloudy weather chain, the balance equation for Sunny combines contributions from both Sunny and Cloudy starting states.
Baum–Welch algorithm
The Baum–Welch algorithm learns HMM parameters from observations by alternating expected hidden counts and parameter updates.
Baum–Welch uses smoothed state information when the training record contains output but no weather labels.
Beam search
Beam search speeds decoding by retaining promising partial paths and pruning weaker ones, which can discard the eventual best path.
A narrow beam search may prune a word hypothesis before later audio would have supported it.
Belief state
A belief state is a distribution over possible hidden states that summarizes the agent’s current uncertainty.
A belief state with two corridor peaks retains two plausible locations for the same physical robot.
Bigram model
A bigram model approximates each next word’s probability using one preceding word, replacing dependence on a longer history.
The bigram model estimates a word transition from counts of neighboring words in training text.

C

Consistency
Consistency means an estimator approaches its target as sample count grows; particle-filter consistency applies at a fixed time.
Consistency supports using more particles, but it does not make a finite run free of sampling error.

D

Data association
Data association assigns sensor readings to their possible generating objects, allowing a tracker to connect detections over time.
Two nearby moving objects can create competing data-association hypotheses for a new detection.
Discretization
Discretization represents a continuous quantity using a finite set of values or bins, trading resolution against state-space size.
Temperature discretization from 10 °C to 20 °C at 0.1 °C intervals includes 101 grid values.
Dynamic Bayesian network
A dynamic Bayesian network represents a changing state through multiple variables with dependencies within or across time steps.
A DBN can model several moving objects without explicitly storing every joint transition entry.

E

Evidence likelihood
The evidence likelihood is the probability of an observation sequence under a model, summed over its possible hidden paths.
Under a solar-panel weather HMM, the evidence likelihood for readings Low, Low, High is 0.1113, larger than any single path’s joint score.
Evidence sequence
An evidence sequence is the ordered series of observed values used to infer hidden states or evaluate a temporal model.
Low, Low, High is an evidence sequence of three panel readings, not a weather-state path.

F

Filtering
Filtering estimates the distribution of the current hidden state given all observations received through the current time.
Online filtering revises a robot’s current position belief as each new range reading arrives.
Fixed-lag smoothing
Fixed-lag smoothing revises the state a chosen number of steps behind the present, allowing a limited delay for later evidence.
A tracker using a three-step lag waits for three later readings before reporting a past location.
Forward algorithm
The forward algorithm recursively predicts states and weights them by observations, summing contributions from earlier paths.
The forward algorithm processes one panel reading at a time without enumerating complete weather histories.
Forward–backward algorithm
The forward–backward algorithm combines stored forward beliefs with recursively computed future likelihoods to smooth each time step.
A forward–backward pass revises an entire recorded trajectory after the last observation is available.
Free parameter
A free parameter is an independently chosen model value after constraints, such as probabilities summing to 1, are applied.
A transition row with three entries has two free parameters because the third is determined.

H

Hidden Markov model
A hidden Markov model combines a hidden Markov chain with observations whose likelihoods depend on the current state.
A solar-panel HMM infers weather from High or Low output readings while allowing either weather to produce High.
Hidden state
A hidden state is a state value the agent cannot directly observe and must estimate from its model and available evidence.
Weather is the hidden state when the agent sees panel output but does not see the sky.

I

Importance weight
An importance weight measures a sample’s contribution to an estimate; in the bootstrap particle update it is the sensor likelihood.
If Low solar output has likelihood 0.7 under Cloudy, each Cloudy particle receives weight 0.7 when the sensor reports Low.
Irreducibility
Irreducibility means that every state in a chain can reach every other state along some path with positive probability.
A two-state weather chain is irreducible when either weather state can reach the other in one move.

K

Kalman filter
A Kalman filter is an exact mean-and-covariance filter for a Gaussian prior with linear motion and observation models and Gaussian noise.
A suitable Kalman filter combines noisy position measurements with motion estimates in tracking.

L

Language model
A language model assigns probabilities to word sequences, providing a prior preference for plausible sequences in recognition.
A language model can make “recognize speech” win over a similar-sounding phrase despite a slightly lower acoustic likelihood.
Likelihood ratio
A likelihood ratio compares how probable the same observation is under two possible states, measuring its relative support.
If High solar output has likelihood 0.8 under Sunny and 0.3 under Cloudy, its Sunny-to-Cloudy likelihood ratio is about 2.67.
Localization
Localization estimates an agent’s position or pose from motion information, sensor readings, and any available map.
In a corridor with two similar doors, localization keeps both door locations plausible after one ambiguous door report.
Log-likelihood
A log-likelihood is the logarithm of evidence likelihood, computed stably by adding logs of successive conditional totals.
Adding log update totals avoids multiplying hundreds of tiny observation probabilities together.
Log-space decoding
Log-space decoding compares path scores by adding log probabilities, preserving their ranking while avoiding tiny products.
An impossible transition has negative-infinite score during log-space decoding, so it cannot win.
Long-run time fraction
A long-run time fraction is the proportion of steps spent in a state as the observed run becomes arbitrarily long.
An always-swapping chain spends half its steps in each state despite oscillating distributions.

M

Marginal mode
A marginal mode is a state with the greatest probability at one time after other states or times have been summed out.
Combining marginal modes from separate times can fail to produce the most likely complete path.
Markov chain
A Markov chain is a sequence of states whose next-state distribution depends only on the current state once it is known.
The daily weather chain predicts tomorrow from today, without needing the earlier weather history.
Maximum-likelihood estimate
A maximum-likelihood estimate selects model parameters that maximize the probability of the observed training data.
For labeled transitions, the maximum-likelihood estimate of a destination probability is its row frequency.
Mini-forward algorithm
The mini-forward algorithm repeatedly applies a Markov transition model to predict distributions without observation updates.
Running the mini-forward algorithm for several days produces a sequence of weather forecasts.
Mixing time
A mixing time is the number of steps needed to reach a chosen distance from equilibrium from every initial state.
A shorter mixing time means distant weather forecasts lose most of their dependence on recent evidence sooner.
Monte Carlo localization
Monte Carlo localization estimates robot pose with particles moved by noisy motion and weighted against readings from a known map.
Monte Carlo localization can begin with particles spread throughout a building when the start is unknown.
Multimodal belief
A multimodal belief has more than one peak of probability, representing separated alternatives that remain plausible.
A multimodal localization belief can place probability in either of two similar corridors.

N

Normalization
Normalization divides nonnegative weights by their positive total to make a probability distribution summing to 1.
Normalization converts state weights 0.10 and 0.35 into probabilities about 0.2222 and 0.7778 by dividing each by their total.

O

Observation forecast
An observation forecast gives the probability of a future reading by averaging sensor likelihoods over predicted states.
In a Sunny–Cloudy weather HMM, a forecast of High output at the next time combines both Sunny and Cloudy contributions.
Outlier component
An outlier component assigns some sensor probability to unusual readings through a normalized mixture with the regular model.
A sensor outlier component can keep an unexpected reading from making every state weight zero.

P

Part-of-speech tagging
Part-of-speech tagging assigns grammatical labels to words in context; an HMM uses tags as hidden states and words as evidence.
Part-of-speech tagging can distinguish “can” as a modal or a verb in “They can fish.”
Particle
A particle is one sampled hidden-state value; a population of particles approximates a distribution over possible states.
A robot localization particle can store a position and heading, while other particles store alternatives.
Particle filter
A particle filter approximates online state inference by sampling transitions, applying sensor weights, and resampling particles.
A particle filter tracks a continuous pose without maintaining a table for every possible position.
Phone
A phone is a speech sound represented in a recognizer’s pronunciation models, often split into several hidden duration states.
A phone HMM may use beginning, middle, and end states with self-loops for variable duration.
Pose
A pose specifies position and orientation together, describing both where a robot is and which direction it faces.
Two pose particles at the same position can predict different ranges if their headings differ.
Prediction step
A prediction step moves a state distribution through the transition model by adding contributions into each destination.
The prediction step can increase Cloudy probability even before any new sensor reading arrives.
Pseudo-count
A pseudo-count is an added count used in probability estimation to reduce the effect of sparse or unobserved outcomes.
Adding a pseudo-count to every destination prevents a short training record from creating zero transitions.

R

Reinitialization
Reinitialization replaces the particle population from a recovery distribution when existing particles cannot support a usable update.
All-zero sensor weights require reinitialization or another recovery step before weighted resampling.
Resampling
Resampling draws a new population with replacement according to normalized particle weights and then gives equal weight to the draws.
Resampling can make several copies of a well-supported robot pose while dropping unlikely poses.

S

Sample impoverishment
Sample impoverishment is the loss of distinct particle states or regions as repeated resampling duplicates a few survivors.
Sample impoverishment can erase one of two plausible corridor locations before a later reading resolves them.
Sensor model
A sensor model, also called an emission or observation model, gives the probability of each reading conditional on the state.
In a solar-panel sensor model with Sunny and Cloudy states, Low output has likelihood 0.7 under Cloudy and 0.2 under Sunny.
Simulation
Simulation generates possible runs by drawing an initial state and sampling each successor from the current transition row.
Across many weather simulations, state counts on day 4 estimate the predicted day-4 distribution.
SLAM
SLAM means simultaneous localization and mapping: estimating a robot’s pose together with a map that is initially unknown.
A SLAM system updates map uncertainty as well as position uncertainty while the robot explores.
Smoothing
Smoothing estimates an earlier hidden state using observations up to a later time, including evidence unavailable at that earlier step.
In a weather HMM, a final High reading after day 2 raises the smoothed Sunny probability for day 2 above its filtered value.
State
A state is a complete value of the information a model records about a system at one time step.
A robot state may combine its position and velocity so that its current direction is retained.
State augmentation
State augmentation combines extra information, such as recent history, with the current value to support a first-order model.
State augmentation turns a second-order weather model into a chain over pairs of successive days.
State distribution
A state distribution assigns a probability to each possible state at one time, expressing uncertainty about the system.
A state distribution of (0.72, 0.28) assigns 72% probability to Sunny on a particular day.
Stationary distribution
A stationary distribution is a normalized nonnegative state vector unchanged by one application of the transition model.
A weather chain whose stationary distribution gives Sunny probability two thirds still has individual days that change.

T

Time-homogeneity
Time-homogeneity means that a model applies the same transition probabilities at every step, even while state probabilities change.
The time-homogeneous weather model keeps its transition rows fixed from the first day onward.
Transition matrix
A transition matrix lists the probabilities of moving between states, with one normalized destination row per current state here.
In a weather transition matrix with Sunny and Cloudy states, a Sunny row of 0.8 for Sunny and 0.2 for Cloudy gives tomorrow’s chances after a sunny day.
Trellis
A trellis is a graph with a layer of possible states at each time and edges representing allowed transitions between layers.
A Viterbi trellis shares state-ending prefixes so decoding avoids checking every complete path.
Trigram model
A trigram model predicts a word conditional on the previous two words, extending a bigram’s context by one word.
A trigram model can distinguish next-word probabilities after two different two-word prefixes.

V

Viterbi algorithm
The Viterbi algorithm uses dynamic programming to find a hidden-state path with the greatest joint score for observed evidence.
In a solar-panel weather HMM, Viterbi returns Cloudy, Cloudy, Sunny for the readings Low, Low, High.

W

Weight degeneracy
Weight degeneracy occurs when a few particles hold nearly all the total weight, leaving most samples with little influence.
Repeated likelihood multiplication can cause weight degeneracy unless the population is refreshed.

About this lesson

By StudeliReport a mistake

Make your own Study Materials

Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.

Get Started