# Confused with how to actually calculate Bayesian probability

As a challenge, I'm trying to implement the following:

Note that $$s_1,s_2$$ refer to the central tile of the ship.

I'm using MATLAB to generate an image of $$P(X|D)$$ that will update after each new bit of data (collected when the user enters a new set of coordinates to fire a missile at).

Consider the first move. Let's say the true ship positions are as shown in the picture, and let's say the user guesses (5,5) and receives the feedback "miss" such that the data becomes $$D=\{ \text{"miss" at "} (5,5) \}$$.

Next,

1. I have set a prior distribution $$P(s_1,s_2)$$ that puts more weight on the central squares since this is the most likely location of $$s_1$$ and $$s_2$$.
2. We need to calculate $$p(X|D) = \displaystyle\sum_{s_1,s_2} p(X|s_1,s_2) \frac{p(\text{miss at } (5,5)|s_1,s_2) p(s_1,s_2)}{p(\text{miss at } (5,5))}$$

Let's deal with each term in the above expression one at a time:

$$p(\text{miss at } (5,5)|s_1,s_2)$$

I think I am right in saying that since we are summing over all $$s_1,s_2$$, the term $$p(\text{miss at } (5,5))$$ will be:

(a) = 0 if $$s_1 \in \{ (5,3),(5,4),(5,5),(5,6),(5,7)\}$$

(b) = 0 if $$s_2 \in \{ (3,5),(4,5),(5,5),(6,5),(7,5)\}$$

(c) = 1 for all other $$s_1,s_2$$

which means I still need to sum over 90 possibilities. Is that right?

$$p(s_1,s_2)$$

Easy - I have a prior distribution for ship positions

$$p(D)$$

Well we can expand this term as $$p(D) = \displaystyle\sum_{s_1,s_2} p(D|s_1,s_2)p(s_1,s_2)$$ but something about this doesn't seem right to me since it's putting a $$\displaystyle\sum_{s_1,s_2}$$ sum inside another $$\displaystyle\sum_{s_1,s_2}$$ sum, and essentially getting me into an infinite loop, no? Is this term much simpler than I'm thinking?

$$p(X|s_1,s_2)$$

I'm confused by this term. Can someone help me?