# How to incorporate per-observation emission priors into HMM

I have a two-state HMM, in which my belief in emission probabilities depends on the observation. Basically, in addition to the two vectors of emission spectra (one for each state), I also have two vectors of priors that depend on parameters other than state "history". In other words, they have nothing to do with transition probabilities.

I'm wondering what's the best way to incorporate them into the HMM. Using the priors just to define the initial states doesn't seem informative enough. On the other hand, using posteriors p(State)*p(Obs|State) rather than likelihoods p(Obs|State) as my emission spectra is probably also not a good idea as any sort of bias will be amplified in the HMM.

Is there a better way to do this?

Say, you have a descrete HMM model, i.e., transition probabilities $A_{ij} = P(q_{t+1}=S_i~|~q_t=S_j)$, and emission probabilities $B_{i}(k) = P(o_t = V_k~|~q_t=S_i)$, where $q$'s denote states in the sequence, $o$'s denote observations, the state space $\mathcal{S} = \{S_1,\dots,S_N\}$ and possible outcomes are $\mathcal{V} = \{V_1,\dots,V_K\}$, $t$ indexes the time (position in a sequence).
Now, if you know (somehow) transition probabilities $A$ and emission probabilities $B$, and want to incorporate some priors $B^{\text{prior}}$ you believe in, the best way is use multiplication $B^{\text{new}}_{i}(k) = B_{i}(k) \cdot B^{\text{prior}}_{i}(k)$ and then renormalize the conditional probabilities. The meaning of this is to give weights to the original emission probabilities according to your prior knowledge.
Another scenario, is when you want to learn transition matrix and emission probabilities from a set of given sequences $\mathcal{O} = \{\vec O_1, \dots, \vec O_L\}$. In this case, we should examine the M-step of the commonly used EM algorithm for HMM learning a bit more in depth. According to the M-step, we have the following update rule $$\bar B_i(k) = \frac{\sum_{l=1}^L\left(\sum_{t=1}^{T_l}\gamma_t^l(j)\cdot\mathbb{1}[o_t^l = v_k]\right)}{\sum_{l=1}^L\left(\sum_{t=1}^{T_l}\gamma_t^l(j)\right)} = \frac{\sum_{l=1}^L\left(\sum_{t=1}^{T_l}P(q_t = S_j, o_t^l = v_k~|~\vec O_l; \theta)\right)}{\sum_{l=1}^L\left(\sum_{t=1}^{T_l}P(q_t = S_j~|~\vec O_l; \theta)\right)},$$ where $\gamma$ is one of the precomputed statistics on the E-step, $\gamma_t^l(j) = P(q_t = S_j~|~\vec O_l; \theta)$, and $\mathbb{1}[\cdot]$ is the indicator function, and $\theta$ denotes the current model parameters.
Now in order to incorporate $B^{\text{prior}}$ into the model, the right way would probably be to weight all the observation sequences according to this prior, i.e., change the M-step formula to the following $$\tilde B_i(k) = \frac{\sum_{l=1}^L\left(\sum_{t=1}^{T_l}P(q_t = S_j, o_t^l = v_k~|~\vec O_l; \theta)\right)P_{\text{prior}}(\vec O_l;\theta)}{\sum_{l=1}^L\left(\sum_{t=1}^{T_l}P(q_t = S_j~|~\vec O_l; \theta)\right)P_{\text{prior}}(\vec O_l; \theta)},$$ where $P_{\text{prior}}(\vec O_l; \theta)$ is computed according to the transition matrix of the current model $\theta$, and prior emissions you have $B^{\text{prior}}$. An intuition behind such way of including prior is that you do not regard all the sequences of observations as equally possible, but judge them according to your prior knowledge.