AI Glossary / Probabilistic machine learning / Advanced
Bayesian hidden Markov model
Definition
A Bayesian hidden Markov model is a probabilistic sequence model that places prior distributions on uncertain model parameters and updates them using observed data. It represents an unobserved sequence of states alongside the observations those states generate, retaining uncertainty about both states and parameters in posterior inference.
What it means
A sequence of observations may reflect changing conditions that cannot be measured directly. A hidden Markov model represents those conditions as latent states. Transition probabilities describe movement between states, and emission distributions describe the observations associated with each state.
The Bayesian element concerns uncertainty about model parameters, such as transition probabilities or emission means. Merely calculating probabilities for hidden states using fixed fitted parameters does not by itself provide a full Bayesian treatment of parameter uncertainty. Different plausible parameter settings can imply different interpretations of the same observations.
How it works
Specify an initial-state distribution, transition model, emission model and priors for unknown parameters. Combine these with the observed sequence to obtain a posterior over parameters and hidden states.
For a finite-state HMM, a forward calculation can sum over hidden paths efficiently when evaluating the likelihood. Parameter inference can then use methods such as Markov chain Monte Carlo. State probabilities conditional on parameter draws can be averaged to account for parameter uncertainty. Initial-state handling and sequence boundaries must be specified; a new independent sequence should not automatically be treated as a continuation of the previous one.
Three practical examples
- A maintenance analyst could model sequences of vibration readings using latent operating regimes. Those inferred regimes would require engineering interpretation rather than automatically proving a particular physical fault.
- A service team could investigate whether call-volume sequences alternate between recurring demand conditions. Posterior predictions could express uncertainty about both the next condition and its likely observations.
- A research group could compare several prior assumptions about persistence in a simulated process. This would reveal how limited data allow prior choices to influence inferred transitions.
Think of it this way
Imagine hearing sounds from behind a closed workshop door. You infer which activity is occurring, but you may also be unsure how often the workers change activities or what each activity sounds like. State uncertainty concerns what is happening now. Parameter uncertainty concerns the rules connecting activities and sounds. A Bayesian HMM can represent both within one model.
Worked example
Construct an original two-state HMM with hidden states 0 and 1. The initial state is equally likely to be either. At each time, the observed binary value matches the hidden state with probability 0.80. Observations are independent conditional on the hidden path. The probability q of remaining in the same state is fixed but unknown: assign equal prior probability to q=0.90 and q=0.60.
Observe the sequence 1,1. To calculate its likelihood, sum the contributions from hidden paths 00,01,10 and 11. For any q, these contributions are 0.5q(0.2)(0.2), 0.5(1−q)(0.2)(0.8), 0.5(1−q)(0.8)(0.2) and 0.5q(0.8)(0.8).
Their sum is 0.16+0.18q. Consequently, the likelihood is 0.322 for q=0.90 and 0.268 for q=0.60. With equal prior weights, the posterior probability of q=0.90 is 0.322/(0.322+0.268), approximately 0.545763. Two matching observations provide only modest evidence for the more persistent model.
Now ask whether the second hidden state is 1. The likelihood contributions from paths 01 and 11 sum to 0.296 under q=0.90 and 0.224 under q=0.60. Averaging the joint probabilities over the prior and normalizing gives (0.296+0.224)/(0.322+0.268), approximately 0.881356. This state probability differs from the parameter probability above: they answer different questions. The discrete two-value prior is a teaching choice, not a standard requirement.
Illustrative case study
Fictional equipment-monitoring company Fern Signal investigates whether a Bayesian HMM can describe recurring machine operating patterns. Engineers provide plausible ranges for observation noise and review whether rapid regime changes are physically credible. The team checks simulated data before analyzing recorded sensor sequences.
It reports state probabilities alongside predictive intervals and explores sensitivity to persistence priors. Engineers compare inferred patterns with maintenance records instead of assigning fault names solely from numerical state labels. This fictional case illustrates model interpretation and validation; it asserts no detection accuracy, operational savings or confirmed causal diagnosis.
Common misconceptions and mistakes
“Hidden states are observed facts.” They are latent quantities inferred under the model and its assumptions.
“A Bayesian HMM automatically discovers the correct number of states.” Many formulations fix that number; learning it requires additional modeling or comparison.
“Parameter means can always replace posterior averaging.” Predictions and state probabilities can depend nonlinearly on parameters, so that substitution can lose relevant uncertainty.
“State 1 has a universal meaning.” State labels can be interchangeable unless the model or interpretation establishes an identifying convention.
“Independent state draws reconstruct a valid posterior path.” Marginal state probabilities do not capture all temporal dependence in the joint posterior.
Business use
Consider this model when ordered observations plausibly arise from recurring latent regimes and uncertainty matters to decisions. Check whether the state-transition and emission assumptions suit the process, and compare predictions with simpler alternatives. Report how priors, state count and inference diagnostics affect conclusions. Keep probabilistic regime assignments separate from verified operational events, especially when people will act on labels such as normal, overloaded or faulty.
People also ask
Must observations be discrete?
No. Emissions can be continuous or discrete, depending on the model.
Is every HMM Bayesian?
No. HMM parameters can also be fitted by non-Bayesian methods.
Does the Markov assumption make observations independent?
No. The latent sequence creates dependence; conditional assumptions must be distinguished from marginal behavior.
Check your understanding
What does 0.545763 represent in the example?
Answer: posterior probability that the persistence parameter equals 0.90.
What does 0.881356 represent?
Answer: posterior probability that the second hidden state is 1, accounting for parameter uncertainty.
Why sum over four hidden paths?
Answer: none is directly observed, and each can contribute to the likelihood of the observed sequence.
Related terms
- Hidden Markov model
- Forward algorithm
- Posterior predictive distribution
- Bayesian inference
- latent state
- transition matrix
- emission distribution
- label switching
Learn next
Enumerate hidden paths for a short two-state sequence. Then study how the forward algorithm replaces exhaustive enumeration and how parameter uncertainty enters posterior predictions.
More in Probabilistic machine learning
- BatchBALD - BatchBALD is a Bayesian active-learning acquisition method that selects a batch of examples by estimating how much their labels jointly reveal about a...
- Bayes-adaptive Markov decision process
- Bayesian active learning by disagreement - Bayesian active learning by disagreement, usually abbreviated BALD, is an acquisition criterion that selects an example whose unknown label is expected to...
- Bayesian lasso - The Bayesian lasso is a Bayesian regression approach that uses Laplace, or double-exponential, priors to shrink coefficients toward zero.
- Bayesian logistic regression - Bayesian logistic regression models a binary outcome using a logistic probability function and prior distributions over regression coefficients.
- Bayesian optimization acquisition function - A Bayesian optimization acquisition function scores possible evaluations using the current probabilistic model of an objective.
Sources
Stan User's Guide, Time-Series Models, Hidden Markov models section, on parameter inference, marginalized likelihoods and posterior state probabilities: https://mc-stan.org/docs/stan-users-guide/time-series.html The two-parameter calculation and fictional business scenarios are original illustrations.
Previous: Bayesian game Next: Bayesian history matching