# A Simplified Matrix Formulation for Sensitivity Analysis of Hidden Markov Models
## 3 Sensitivity Analysis of Filtering Probability
### Observation Parameter Variation
#### 3.3.1 Observation Matrix Decomposition  
In the proposed algorithm, to calculate the coefficients in a series of forward matrices \(F^{k},k=1,...,t\), the Observation Matrix \(O\) is divided into \(\widehat{O}\) and \(\widehat{O}\) that are independent of and dependent on \(\theta_{o}\), respectively, for mathematical convenience. The matrices \(\widehat{O}\) and \(\widehat{O}\) are computed based on the proportional co-variation assumed as shown in Equation (4). Let us explain the Observation Matrix \(O\) decomposition by considering the HMM presented in the previous section and let the observation parameter \(\theta_{o}\) be \(o_{2,1}=p(y_{1}^{t}|x_{2}^{t})\). The observation matrix \(O\) becomes a function of \(\theta_{o}\) based on the proportional co-variation assumption shown in Equation (4) as follows. \[O(\theta_{o})=\left[ \begin{array}{cccc}o_{1,1}&o_{1,2}&\cdots&o_{1,m}\\ \theta_{o}&\frac{o_{2,2}(1-\theta_{o})}{1-o_{2,1}}&\cdots&\frac{o_{2,m}(1- \theta_{o})}{1-o_{2,1}}\\ \vdots&\vdots&\ddots&\vdots\\ o_{n,1}&o_{n,2}&\cdots&o_{n,m}\end{array} \right]\]  
This matrix is decomposed into \(\widehat{O}\) and \(\widehat{O}\) that are independent of and dependent on \(\theta_{o}\), respectively, such that \(O(\theta_{o})=\widehat{O}+\widehat{O}(\theta_{o})\), just as we decomposed \(A(\theta_{a})=\bar{A}+\widehat{A}(\theta_{a})\) in Section 3.1.1. Once the Observation Matrix is decomposed into \(\widetilde{O}\) and \(\widehat{O}\), in the SMF, they are represented as \(n\times n\) diagonal matrices. For example, the sequence of observations \(y_{2}^{1},y_{1}^{2}\) and \(y_{3}^{3}\), the corresponding diagonal matrices become  
\[\widehat{O}^{1} =diag(\widehat{O}_{;2}),\quad\widehat{O}^{2}=diag(\widehat{O}_ {;1})\quad\text{and}\quad\widehat{O}^{3}=diag(\widehat{O}_{;3})\] \[\widehat{O}^{1} =diag(\widehat{O}_{;2}),\quad\widehat{O}^{2}=diag(\widehat{O}_ {;1})\quad\text{and}\quad\widehat{O}^{3}=diag(\widehat{O}_{;3})\]  
3.2 SMF for Sensitivity Analysis of the Filtering Probability to the Observation Parameter Variation  
In the simplified matrix representation, the sensitivity function \(p(x_{v}^{t},\mathbf{y_{e}^{1:t}})(\theta_{o})\) can be written as a simple matrix-vector multiplication. From Equation (9), it follows that for \(t=1\) we have the constant \(p(x_{v}^{1},\mathbf{y_{e}^{1}})(\theta_{o})=o_{v,\mathbf{e}^{1}}(\theta_{o}) \cdot\gamma_{v}\), which becomes \(p(x_{v}^{1},\mathbf{y_{e}^{1}})(\theta_{o})=O^{1}(\theta_{o})\Gamma^{\tau}\) in the SMF. For \(t>1\), we have  
\[p(x_{v}^{t},\mathbf{y_{e}^{1:t}})(\theta_{o})=o_{v,\mathbf{e}^{1}}(\theta_{o} )\cdot\sum_{z=1}^{n}a_{z,v}\cdot p(x_{v}^{t-1},\mathbf{y_{e}^{1:t-1}})(\theta_ {o}),\]  
which is represented as  
\[p(X^{t},\mathbf{y_{e}^{1:t}})(\theta_{o})=O^{t}(\theta_{o})A^{\intercal}p(X^{ t-1},\mathbf{y_{e}^{1:t-1}})(\theta_{o})\]The derivation of the proposed technique for the sensitivity analysis of the forward (filtering) probability \(p(x_{v}^{t},\mathbf{y}_{\mathbf{e}}^{1:t})(\theta_{o})\) with observation parameter variation \(\theta_{o}=o_{r,s}\) is formulated in Algorithm 3.