# Compute likelihood of state given multiple observations?

I am trying to use Bayes formula to compute the likelihood of a given state given a collection of independent but not sequenced observations - knowing the priors and knowing the probabilities of being in the state given each observation.

In other words for pre-defined states $$S = \{S_1,\dots,S_m\}$$ and possible observations $$O=\{O_1,\dots,O_n\}$$, the prior and conditional probabilities are already known:

$$P(S_i) = \pi_i$$ $$P(S_i|O_j) = \rho_{ij}$$

(Note the second formula is not the "observation emission probability" but rather the state given observation probability.)

Suppose now I have collected a set of $$k$$ observations $$\Theta=\{\theta_1,\dots, \theta_k\}$$ and wish to compute for each state $$i$$:

$$P(S_i | \Theta) = P(S_i | \theta_1,\dots,\theta_k)$$

i.e. to work out the most likely state given the observations. I am having a brainfade as trying to use Bayes formula directly goes nowhere:

$$P(S_i | \theta_1,\dots,\theta_k) = \frac{P(\theta_1,\dots,\theta_k|S_i)P(S_i)}{\alpha}$$

I see the relevance of Hidden Markov Models (HMMs) in the mathematics but there is no natural sequence I'm dealing with here it is just a collection of unordered observations. What's the correct way to compute this?? (Pretend it's a HMM with a flat transition probability matrix??)

Suppose I accepted some independence assumptions and continued the derivation as follows:

$$= \frac{P(\theta_1|S_i)\cdot \dots \cdot P(\theta_k|S_i)P(S_i)}{\alpha}$$

Then applied Bayes formula again to each term:

$$= \frac{\frac{P(S_i|\theta_1)P(\theta_1)}{P(S_i)}\cdot \dots \cdot \frac{P(S_i|\theta_k)P(\theta_k)}{P(S_i)} P(S_i)}{\alpha}$$

Seems to be getting a bit silly and now I have to come up with $$P(\theta_i)$$ priors too (possible but surprised I need this) - what's going on and what's the correct way to compute this??

This is correct: \begin{align}\mathbb P(S=S_i|\theta_1,\ldots,\theta_k) \propto \frac{\mathbb P(S=S_i|\theta_1)p(\theta_1)}{\pi_i}\cdots \frac{\mathbb P(S=S_i|\theta_k)p(\theta_k)}{\pi_i} \pi_i\\ \propto \mathbb P(S=S_i|\theta_1)\cdots \mathbb P(S=S_i|\theta_k) \pi_i^{-k+1} \end{align} and the $$p(\theta_j)$$'s play no role there.

• Thanks for clarifying that the priors are not needed good catch! Is there a name for this application of Bayes formula where the known conditional probabilities are inverted? Sep 8, 2021 at 9:51

It's a little bit confusing as at the beginning we define a relationship between the probability of a state given a single observation but now we are looking at a set of observations. Do we know with certainty that all observations come from the same state? Assuming that we do then the solution by Xi'an is correct.

Reproducing it here with a few extra steps, without loss of generality let $$k=2$$:

$$\begin{equation} \mathit{P}(S_i|\theta_1, \theta_2) = \frac{\mathit{P}(\theta_1, \theta_2|S_i)\mathit{P}(S_i)}{\mathit{P}(\theta_1, \theta_2)} \hspace{0.5cm} \text{(Bayes Theorem)} \end{equation}$$

$$\begin{equation} = \frac{\mathit{P}(\theta_1|S_i)\mathit{P}(\theta_2|S_i)\mathit{P}(S_i)}{\mathit{P}(\theta_1)\mathit{P}(\theta_2)} \hspace{0.5cm} \text{(Independence Assumption)} \end{equation}$$

$$\begin{equation} = \frac{\mathit{P}(\theta_1|S_i)}{\mathit{P}(\theta_1)}\frac{\mathit{P}(\theta_2|S_i)}{\mathit{P}(\theta_2)}\mathit{P}(S_i) \hspace{0.5cm} \end{equation}$$

$$\begin{equation} = \frac{\mathit{P}(S_i|\theta_1)}{\mathit{P}(S_i)}\frac{\mathit{P}(S_i|\theta_2)}{\mathit{P}(S_i)}\mathit{P}(S_i) \hspace{0.5cm} \text{(Bayes Theorem)} \end{equation}$$

And so in general:

$$\begin{equation} \mathit{P}(S_i|\theta_1,...,\theta_n) =\frac{\mathit{P}(S_i|\theta_1)}{\mathit{P}(S_i)}...\frac{\mathit{P}(S_i|\theta_n)}{\mathit{P}(S_i)}\mathit{P}(S_i) = \mathit{P}(S_i|\theta_1)...\mathit{P}(S_i|\theta_n)\mathit{P}(S_i)^{-(n-1)} \end{equation}$$

• Thanks for the derivation. Yes it is an unusual situation where the observations are known with certainty to be from the same source (i.e. state) but the state itself is unknown. Is there a name for this sort of Bayesian analysis but with inverted knowledge of the conditional probabilities? Sep 8, 2021 at 9:49
• I'm not aware of any formal name for this other than Bayesian analysis. I'm not sure about your precise use case, but you might be interested in changepoint detection as a topic. It looks to identify periods of time which belong to the same state given some observations. Sep 14, 2021 at 9:08
• I'm getting weird results with this. Suppose P(Si | θ1) = 0.75and P(Si | θ2) = 0.75and P(Si) = 0.5. The result is then 0.75 x 0.75 / 0.5 = 1.125 > 1. Is this situation impossible or am I missing something in the calculation ? Oct 6, 2022 at 6:59