UTF8gbsn
Hidden Markov model(HMM) is a statistical learning model which used in
labeled problems. We will introduce the definition of HMM first here and
there will be an example followed by the HMM definition.
definition
HMM is a time sequence statistics model which describes a sequence
randomly generated from an markov chain with unobserved state sequence.
The observation sequence is generated from the steps of the state
sequence.
-
Let Q Q Q be the states collection Q = { q 1 , q 2 , ⋯ , q N } Q=\{q_1,q_2,\cdots, q_N\} Q={q1,q2,⋯,qN}
-
Let V V V be the observation collection
V = { v 1 , v 2 , ⋯ , v M } V = \{v_1, v_2,\cdots, v_M\} V={v1,v2,⋯,vM} -
Let I I I be a state sequence with length of T T T.
T = ( i 1 , i 2 , ⋯ , i T ) T=(i_1,i_2,\cdots, i_T) T=(i1,i2,⋯,iT) -
Let O O O be the corresponding observation sequence.
O = ( o 1 , o 2 , ⋯ , o T ) O=(o_1, o_2, \cdots, o_T) O=(o1,o2,⋯,oT)
-
transition matrix A A A A = [ a i j ] N × N A=[a_{ij}]_{N\times N} A=[aij]N×N
a i j = P ( i t + 1 = q j ∣ i t = q i ) , i = 1 , 2 , ⋯ , N ; j = 1 , 2 , ⋯ , N a_{ij}=P(i_{t+1}=q_j|i_t=q_i), i = 1,2,\cdots, N; j = 1,2,\cdots, N aij=P(it+1=qj∣it=qi),i=1,2,⋯,N;j=1,2,⋯,N -
observation matrix B B B B = [ b j ( k ) ] N × M B=[b_{j(k)}]_{N\times M} B=[bj(k)]N×M
b j ( k ) = P ( o t = v k ∣ i t = q j ) , k = 1 , 2 , ⋯ , M ; j = 1 , 2 , ⋯ , N b_j(k)=P(o_t=v_k|i_t=q_j), k=1,2,\cdots, M; j=1,2,\cdots, N bj(k)=P(ot=vk∣it=qj),k=1,2,⋯,M;j=1,2,⋯,N -
The initial state vector is π = ( π i ) \pi=(\pi_i) π=(πi)
π i = p ( i 1 = q i ) , i = 1 , 2 , ⋯ , N \pi_i=p(i_1=q_i), i=1,2,\cdots, N πi=p(i1=qi),i=1,2,⋯,N
Finally, we can use a tuple to describe a HMM. λ = ( A , B , π ) \lambda=(A,B,\pi) λ=(A,B,π)
A , B , π A,B,\pi A,B,π are called the HMM essentials.
The two hypotheses of HMM
-
The state of time t t t is depend and only depend on the previous
state of time t t t.
P ( i t ∣ i t − 1 , o t − 1 , ⋯ , i 1 , o 1 ) = p ( i t ∣ i i − 1 ) , t = 1 , 2 , ⋯ , T P(i_t|i_{t-1},o_{t-1},\cdots,i_1,o_1)=p(i_t|i_{i-1}),t=1,2,\cdots,T P(it∣it−1,ot−1,⋯,i1,o1)=p(it∣ii−1),t=1,2,⋯,T -
The observation of time t t t is depend and only depend on the state
of time t t t.
P ( o t ∣ i T , o T , i T − 1 , o T − 1 , ⋯ , i t + 1 , o t + 1 , i t , i t − 1 , o t − 1 , ⋯ , i 1 , o 1 ) = P ( o t ∣ i t ) P(o_t|i_T, o_T, i_{T-1},o_{T-1},\cdots, i_{t+1},o_{t+1}, i_t,i_{t-1}, o_{t-1}, \cdots, i_1,o_1)=P(o_t|i_t) P(ot∣iT,oT,iT−1,oT−1,⋯,it+1,ot+1,it,it−1,ot−1,⋯,i1,o1)=P(ot∣it)
example
Now, we will list an example here to illustrate the details of HMM.
There are 4 boxes with balls in it.
-
Box 1 contains 5 red balls and 5 white balls.
-
Box 2 contains 3 red balls and 7 white balls.
-
Box 3 contains 6 red balls and 4 white balls.
-
Box 4 contains 8 red balls and 2 white balls.
The selection scheme is described by the following text.
-
Firstly, we randomly choose a box and pick a ball from it. Then, we
recognise its color and put it back to the box. -
Secondly, we will turn to the next box by the following rules. The
rules: If the current box is box 1, we will choose the box 2 as the
next box; If the current box is box 2 or 3, we will choose box on
the left or right of the current box by probability 0.4 and 0.6; If
the current box is 4, we will choose box 4 or box 3 as the next box
by probability 0.5 respectively. -
After we get our next box, we will pick one ball from it, recognize
its color and put it back. -
Repeat five times. we will get a color sequence.
O={红, 红, 白, 白, 红}
Let us use the formal expression to describe this HMM
Q={box 1, box 2, box 3, box 4}, N = 4
V = {red, white} , M = 2
The length of state sequence and observation sequence is
T
=
5
T=5
T=5. The
initial probability distribution is
π = { 0.25 , 0.25 , 0.25 , 0.25 } \pi=\{0.25, 0.25, 0.25, 0.25\} π={0.25,0.25,0.25,0.25}
The transimit matrix is ( 0 1 0 0 0.4 0 0.6 0 0 0.4 0 0.6 0 0 0.5 0.5 ) \left( \begin{array}{cccc} 0 & 1 & 0 & 0 \\ 0.4 & 0 & 0.6 & 0 \\ 0 & 0.4 & 0 & 0.6 \\ 0 & 0 & 0.5 & 0.5 \end{array} \right) ⎝⎜⎜⎛00.400100.4000.600.5000.60.5⎠⎟⎟⎞
The observation matrix is
B = ( 0.5 0.5 0.3 0.7 0.6 0.4 0.8 0.2 ) B=\left( \begin{array}{cc} 0.5 & 0.5 \\ 0.3 & 0.7 \\ 0.6 & 0.4 \\ 0.8 & 0.2 \end{array} \right) B=⎝⎜⎜⎛0.50.30.60.80.50.70.40.2⎠⎟⎟⎞