I need help understanding and solving two questions from HMM. Please see these matrices,
where
the hidden states are H = happy and S = sad.
Pi is the initial probability table
P(x[t] | x[t-1]) is the transition table and
p(y[t] | x[t]) is the emission table
How do I comprehend:
If at time t-1 we have p(x[t−1] = H | y[1:t−1]) = 1, what are the values of p(x[t] = H | y[1:t−1])?
What about
p(x[t] = H | y[1:t−1]; y[t] = Play)?
I do not know how to comprehend and therefore calculate these questions. How could I calculate these values with matrix calculations?
First of all, Given that data, let's answer:
p(x[t] = H | y[1:t−1])
, then p(x[t] = H | y[1:t−1]; y[t] = Play)
should be quite intuitive. But please note that so is not a site for doing your homework.
Anyhow, when dealing with Markov chains, keep one thing in mind: History doesn't matter! So no matter what your previous observations were, your current observation
(y
) will only depend on the current state x[t]
. (don't tell that your history teacher that, she will try to make you repeat the class, as it was in my case).
So: p(x[t−1] = H | y[1:t−1]) = 1
is the same as saying that the previous state was Happy (H
). That "given" y[1:t−1] doesn't give us any info.
OK, what do we know about the p(x[t]|x[t-1]=H)
? Well, the first row, in the first matrix tells you what the probability of transition from one state to another is.
Now we can answer your first question:
p(x[t] = H) = p(x[t] = H | x[t-1] = H)*p(x[t-1] = H) + p(x[t] = H | x[t-1] = S)*p(x[t-1] = S)
If the previous formula is too much, Hint: p(x[t] = H)
is the unconditional probability of she being happy today.
Since we already know that p(x[t-1] = H) =1
(she was happy yesterday), it means that she was definitely NOT sad yesterday: p(x[t-1] = S) =0 =>
p(x[t] = H) = p(x[t] = H | x[t-1] = H)
, and using the first matrix, you get: 0.6
How about?
p(x[t] = H | y[1:t−1]; y[t] = Play)
, apply "History doesn't matter rule", and you get:
p(x[t] = H | y[1:t−1]; y[t] = Play) = p(x[t] = H | y[t] = Play)
Here's another hint if you want to do it yourself: p(x[t] = H) =0.6
cause we already answered that! You also know that: p(x[t] = H) + p(x[t] = S) = 1
(cause she can only be Happy or Sad, right?)
Now apply the Bayesian rule (which I know is non-intuitive, but there are many good videos on youtube explaining also the intuition behind) and you can write your question like this:
p(x[t] = H | y[t] = Play) = (p(y[t] = Play| x[t] = H) * p(x[t] = H))/p(y[t] = Play)
But then you might say: hey, I already am observing she is playing, you might be tempted to substitute that with 1, not so fast, because in Math, this p(y[t] = Play)
means the unconditional probability.
p(y[t] = Play) = p(x[t] = H)*p(y[t] = Play|x[t] = H) + p(x[t] = S)*p(y[t] = Play|x[t] = S)
So :
p(x[t] = H | y[t] = Play) = (p(y[t] = Play| x[t] = H) * p(x[t] = H))/(p(x[t] = H)*p(y[t] = Play|x[t] = H) + p(x[t] = S)*p(y[t] = Play|x[t] = S))
Now you have no unknowns, Substitute from the tables and calculate.