[Hidden Markov Model] Use backward algorithm to calculate observation sequence probability P (O | λ)
The hidden Markov model is a probabilistic model about time series, which describes the process of randomly generating a sequence of unobservable states from a hidden Markov chain, and then randomly generating an observation from each state to generate the sequence of observations. The model itself is a generative model, which represents the joint distribution of the state sequence and the observation sequence, but the state sequence is hidden and unobservable.
The calculation of observation sequence probability requires effective algorithm support.
Model, A is the state transition probability matrix, B is the observation probability matrix, π is the initial state probability vector
direct calculation method
The direct calculation method is mainly used to illustrate ideas. It is conceptually feasible but computationally unfeasible (the amount of calculation is too large).
Idea:
1. List all possible state sequences with length
2. Find the joint probability of each state sequence and the observation sequence
3. Sum all possible state sequences to get
Input: hidden Markov model and observation sequence
Output: Implementation sequence probability of occurrence,
1) Probability of state sequence
2) For a fixed state sequence, the probability of observing the sequence
3) The joint probability of and appearing simultaneously
4) Sum all possible state sequences to get the probability of the observation sequence
In actual operation, the calculation amount of step 4 is very large, and it is of order
forward algorithm
Forward probability: Given the hidden Markov model, the partial observation sequence at time t is defined as and the state is The probability of is the forward probability, denoted as
Input: hidden Markov model and observation sequence
Output: Observation sequence Probability of occurrence
1) Initial value,
2) Recursion, yes
3) Termination
Calculation amountOrder
Example: box and ball model, state set, observation set
, use the forward algorithm to find
answer:
1) Initial value
A is the state transition probability matrix, B is the observation probability matrix, π is the initial state probability vector, and O is the observation sequence.
——A's i row and j column,——B's i rowcolumn
For example corresponds to Red, corresponds to the first column of the observation set V, and corresponds to the first column of the observation probability matrix B
2) Recursion
row i of B column, is the element corresponding to the first row and column of B
3) Termination
Recurse to T=3 and sum the forward probabilities to get
backward algorithm
Backward probability: Given the hidden Markov model, it is defined that under the condition that the state at time t is , from t+1 to The probability that the partial observation sequence of T is is the backward probability, denoted as
Input: hidden Markov model and observation sequence
Output: Probability of occurrence of observation sequence
1) Initial value,
2) Recursion, yes
3) Termination
Calculation amountOrder
Example: Heshiwa ball model,
, use backward algorithm to find
answer:
1) Initial value
A is the state transition probability matrix, B is the observation probability matrix, π is the initial state probability vector, and O is the observation sequence.
Recursively downward from T=4, generally set the initial value of the backward probability to 1
2) Recursion
ProgressEnd
——A's i row and j column,——B's i rowcolumn
row i of B column, is the element corresponding to the first row and column of B
3) Termination