History of the most simple explanation of hidden Markov model

in case...

If ... one day ... you catch the little goddess Xi Yao ... and in love with her ...

(To say "no ifs" of passers Please select a leash (¯∇¯))

Life is very regular small evening Oh, small evening will in turn go through every day and only experienced the following six things:

Makeup - eat - Chat - self-study - school - to hug.

And small evening behaved, we were together every day, a small city in the evening doing everything to tell you at the moment small evening of emotional state (small evening there are four kinds of emotional states: happy, embarrassed, frustrated, angry )

However, small evening when happy is not necessarily a smiling face, not necessarily a crying face when depressed. Therefore, when in a certain emotional state, every expression face will have a probability of occurrence oh (There are five small evening expression face: crying face, smile, embarrassed face, toot face, facial paralysis face )

But ... we just have a lot of life after many days , suddenly the morning of the day, we have trouble, small evening and just in the physical period, sometimes too upset and say the following words:

"Hey, if you can not portrayed my mental state change process today, then you do not accompany me hum ~"

Although this day you can still observe changes in the expression of the face of the small evening , but that day small evening did not reveal her emotional state, then how to do in order to restore it?

(Say "do not restore direct kick," the children's shoes please stand! Moment! Dog! With!)

Hidden Markov Model

You: "╮ (╯ ▽ ╰) ╭ hey, it is too simple, is not that probability and statistics, random processes hidden Markov model high school Well ~ Is not that a question implicit sequence predicted thing ..."

First-order hidden Markov model a long way:

 

v2-64dd8b1919978f29e835f8afb01a1fe6_b.png

This model looks and complex and interesting and baffling. Oh Do not tube, listen to small talk about this evening slowly strange things good.

Do not control "first-order" What do you mean it (meaning that each state is only implicit in front of a historical state related, do not understand it does not matter). In the above first-order hidden Markov model, there are three hidden states: i.e. black circle omega] 1, [omega] 2 circle, circle ω3. System at any time, in only one of three hidden states. It is called hidden state, because these states are hidden, that is, not passers-by to see the system at a time which is hidden in the state.

The connection between the implicit representation of the state transition probabilities between hidden states: system at a time in a hidden state, but in the next moment may be in a state other hidden, of course, may still be hidden in the current state, so ωi jump from the current state to the next state ωj probability that is wired aij. FIG example, the transition probability from state ω1 ω2 is the connection a21.

FIG red v1, v2, v3, v4 represents observed values. That means the value of the observed value of passers-by can see. Similarly, at a time when the system can only take one kind of observations, we can observe directly (although we do not see at the moment in which hidden state).

Red arrows indicate bij is in the hidden state ωi, we can observe the probability of the observed value vj. It can be seen every time the system, in some hidden state, while Cain state has a certain probability values ​​observed a four observation values.

~ Finished good theory, but we do not know the fun and seemingly inexplicable model what use it. So below is a small evening to display their magic moment!

Small evening of magic

First, the small evening itself into a first-order hidden Markov model!

Xi Yao in this small hidden Markov model, apparently small evening four emotional state is the hidden state ah, passers-by can not be observed directly, only a small evening his mind clear. The small evening expression face, you can always see, so that observations theoretical model of way.

The small evening every day, will experience "make-up - eat - Chat - self-study - school - to hug" process, not that thing went through six time points, while experiencing the six time points, small evening's emotional state will stop random changes, it is not that the state of the hidden Markov model is transferred thing. Of course, each emotional state, every expression face are likely to experience Oh, is that each observations are likely to occur. So draw a map is like this (after the observations of each state implied painting too messy, open draw oh, mend their own brain):

 

v2-6e4b9cfe5d7d5fe1fec660c2abf9ba5b_b.png

Of course, as with the foregoing theoretical model, each state will have a probability is hidden to the following observations Oh (intermediate b12, b13, b14 omitted matter, make their own brain oh):

 

v2-3afeaceac0d733a3c241c29779c4e366_b.png

Look! Is not suddenly discover the hidden Markov model is very reasonable explanation for the small evening! ! ! There are far more reasonable! ! !

Mentioned earlier, will experience small evening of day 6 time points, every evening after a day is small will produce a hidden state sequence, and a sequence of observation . Xi said that while small matter, you can make a lot accompany small evening for several days Oh, so if you really like small intentions evening, then, will record changes in emotional state (hidden state sequence) under small evening every day said to you also recorded small evening every day changes in the expression (observation sequence). Of course, the length of the sequences is always 6 friends.

On the last day with a small evening get along, you still recorded the eve of the day of small changes in the expression (observation sequence), but you want to calculate it is a small evening mood changes this day, that is the hidden state sequence. At this point, the whole thing completely restore small evening's card to the first-order hidden Markov model!

So how to calculate the ultimate goal of using the clues above these small Yao Xi provide it?

AB faction

Your success will "restore Xi Yao small" task card into the hidden Markov model (HMM) in. Then we sort out standardized information and the need to have some information calculated.

Remember these two figures Well? That is why we established a good model.

 

v2-6e4b9cfe5d7d5fe1fec660c2abf9ba5b_b.png

(Hidden state transition diagram)

 

 

 

v2-3afeaceac0d733a3c241c29779c4e366_b.png (Ωi each hidden state probabilities have five kinds of signals can be sent observed)

For the first graph, so many parameters and looks very chaotic, then all the state transition probability aij stored in a matrix A:

 

v2-58ba9a8321c7bf37f8664440b7c21c7f_b.png

Each element aij of the matrix A represents the current state of ωi, ωj is the probability that the next state (i.e., [omega] i to the state transition probability of the state ωj).

For the second graph, when the probability is described (implicit) state is ωj, the signals vk. So with bjk to represent the probability of ωj signals vk. The matrix B stored bjk:

 

v2-48416075ab0c0e54f81b152e340c43d7_b.png

Good ~ A matrix and the B matrix is ​​clear that we need to calculate the model parameter friends. But the argument is only A and B enough?

Think, though A can describe the probability of transition from a state to a state, but every state there must be a sequence beginning Yup, this is the beginning of what it was like, are not described in the matrix A and matrix B.

Therefore, there is a model parameter initial state description, which is described as a probability of each hidden state ωi initial state, referred to as πi. That is, vector π:

 

v2-91bb4430b659e0332157efe0d5d6533e_b.png

After finishing ~ A, B, pi is all we want to model parameters calculated.

Start training!

And we have a hidden state sequence data and the observed sequence corresponding small Yao Xi many days, then how do we use them to train the parameters of the model it.

In fact, this is very simple and very simple matter, the likelihood function directly out to find that the maximum value of the parameter function like natural thing, which is to maximize the likelihood function.

As the name suggests, "natural" is meant, the likelihood function is used to describe a reasonable value of the current model parameters, indirectly reflect the degree of interpretation of the current data set of model parameters of the opponent, so that the maximum likelihood function, meaning that taken so that the most reasonable model parameters, such that the hands of the data set becomes reasonable interpretation model.

You accompany small evening spent 300 days. So you recorded the hidden state sequence segment 300, referred to as Q = q1 q2 q3 ... qT (in fact, qi is represented before ωi), where T = 6 (experienced six times every day, make-up - eat - Chat - self-study - school - to hug).

While the observation sequence corresponding to segment 300, referred to as O = O1 O2 O3 ... OT, the same T = 6.

Then based on maximum likelihood estimation of thought, the direct use of the sample set with the optimization algorithm to estimate the parameters of the HMM friends.

But here for the convenience of the reader to understand, difficult to simplify the article, the direct use of frequencies to approximate the probability (the actual project do not like this ah). So this should be the parameters of HMM estimate:

 

v2-7078825c17ce8c0628e35807fd328cec_b.png

 

v2-9c24abdca138f652aa5b02c633b73428_b.png

 

v2-8bfa407c383c71334154d74edb38a436_b.png

Thus we obtain all model parameters (vector π, the matrix A, matrix B).

Look, therefore, we easily put this small Yao Xi hidden Markov model is complete.

With this model, we will fully see through the small Yao Xi! So, let's start to get the ultimate goal of this task - prediction Xi Yao in small petty temper the day's emotional state sequence (hidden state sequence)!

See through you!

Quantify what we need to do: at a given HMM model (HMM that is known to all the parameters of the model, referred to as μ) and the observation sequence O case, seeking the maximum probability of (hidden) state sequence:

 

v2-51a8d29850f2d4e22650bba4086acf33_b.png

How to calculate it? Viterbi algorithm!

This algorithm around a bit, directly attached to it, do not know if direct look, you can see explanation behind the small evening oh.

 

v2-b0f6ae514a4d81c22b0a467e70d65dcc_b.png

 

v2-08150bb7fb13350c4f8f097d6830a5cc_b.png

 

v2-afcb153f9062dfceb8630c09965dca04_b.png

 

v2-85b3ec6603a56b87ba18d3fdfff27ee5_b.png

The idea of ​​the algorithm is to set up a villain δ (pronounced delta), the villain from time 1, the time has come to T.

In this sense the villain is to record their implicit in each state at each time point t j probability (note that the probability is not calculated from the global observation sequence from t = his own observation a step by step each time 1 cumulative probability that moment in time of the observation value obtained)

The first step in the algorithm: initialize the villain, using the known model parameters πi and BI (O1) (i.e. the state i, the probability of the observed values of O1 emitted, wherein O1 is the observed value. 1 t = time) to give t = 1 time each hidden state value of i δ.

Step Two: The villain at each time t will be hidden in each state to stay for a while. Each hidden state j in, it will look up observations Ot moment, respectively, and assume their preceding in time t-1 of each of the hidden states i hidden state, and assuming a previous time t-1 is the current state of transition probabilities implicit cumulative probability value multiplied by a time before the assumption of an implicit state to the current time, then the current time is calculated so that the total probability of the current state of the hidden hidden state of maximizing the previous time, the best hidden state denoted m right. The cumulative probability of a state before the hidden optimal time δt-1 (m) multiplied by the current and previous state to a time point m at the current time j transition probability state multiplied by the current state of the current time t j sent observations Ot the probability, that is δt (j).

The third step: after the last completed villain δ hidden state last time T, we can pick out the last time from the last time all of the hidden states, i.e. the global maximum cumulative probability δT matter, note that the maximum probability corresponding to the hidden state QT

The fourth step: a step by step way back, write down the time come to the best hidden state T QT optimal state before a hidden time (recall that the second step) to obtain the optimal moment before a hidden state QT-1. Then the same, and then move back to give QT-2, Ql far back as the! Then Q1Q2Q3..QT is the globally optimal sequence of hidden states it! Yao Xi is little emotional state sequence when the petty temper!

After you guess, Xi Yao small moment (be yourself) CRY ... (heart os: actually spent so much effort to teach you how to guess what I was thinking ... How about you might as well just tell trained, trained, trained, ...

Published 33 original articles · won praise 0 · Views 3298

Guess you like

Origin blog.csdn.net/xixiaoyaoww/article/details/104553543