# Observed hidden variables in HMM

I am studying Hidden Markov Models and I'm trying to understand the following exercise:

Consider Hidden Markov Model with hidden states $$h_{1:T} = \{h_1,...,h_T\}$$ and observed states $$v_{1:T}=\{v_1,...,v_T\}$$.

Let $$v_t\in\{0,1,2\}, h_t\in\{0,1\}$$ and the parameters of the model are as follows. $$p(h_1=1)=0.5$$, the transition matrix $$T=\begin{pmatrix} 0.5 & 0.8 \\ 0.5 & 0.2 \end{pmatrix}$$ and the emission matrix $$\begin{pmatrix}0.3 & 0.5 \\ 0.6 & 0 \\ 0.1 & 0.5 \end{pmatrix}$$.

Question 1: Suppose that you observe the sequence of outcomes $$v_{1:10}=[0,1,0,2,0,2,1,0,2,0]$$. Is $$h_1$$ independent of $$h_{10}$$ in $$p(h_{1:10}|v_{1:10})$$ given this particular sequence?

Question 2: Compute the filtering distributions $$p(h_8|v_{1:8})$$ and $$p(h_9|v_{1:9})$$ (Hint: you do not need to run the full Forward algorithm here.).

Answer to question 1: We notice in the emission matrix that $$p(v_t=1|h_t=1)=0$$, so it is certain that in this particular sequence, $$h_2=0,h_7=0$$. Since the distribution $$p(h_{1:10}|v_{1:10})$$ is a Markov chain, $$h_{1:t-1} \perp\kern-5pt\perp h_{t+1:n} | h_t$$, so we have that in this particular sequence, we $$p(h_{1:10}|v_{1:10}) = p(h_{1:10}|v_{1:10},h_2,h_7)$$, making $$h_1$$ and $$h_{10}$$ independent.

Answer to question 2: By the previous question we know that $$p(h_8|v_{1:10},h_7,h_2) = p(h_8|h_7=0)$$. Hence, by the transition matrix, $$p(h_8|h_7=0) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}$$ and for $$p(h_9|v_{1:10})$$:

\begin{align} p(h_9|v_{1:10}) & \propto p(v_9|h_9)\sum_{h_8}p(h_9|h_8)p(h_8|v_{1:8}) \\ & = \begin{pmatrix} p(v_9=2|h_9=0)\left(\frac{1}{2}p(h_9=0|h_8=0)+ \frac{1}{2} p(h_9=0|h_8=1)\right) \\ p(v_9=2|h_9=1)\left)\frac{1}{2} p(h_9=1|h_8=0)+\frac{1}{2}p(h_9=1|h_8=1)\right) \end{pmatrix} \\ & = \begin{pmatrix} 0.1(\frac{1}{2}\frac{1}{2}+0.8\frac{1}{2}) \\ \frac{1}{2}(\frac{1}{2}\frac{1}{2}+0.2\frac{1}{2}) \end{pmatrix} = \begin{pmatrix} 0.065 \\ 0.175 \end{pmatrix} \end{align}

After normalizing it becomes $$0.27, 0.73$$

Is my reasoning correct for these questions?