I'm tackling the following problem:

Your cell phone is constantly trying to keep track of where you are. At any given point in time, for all nearby locations, your phone stores a probability that you are in that location. Right now your phone believes that you are in one of 16 different locations arranged in a grid with the following probabilities (see the figure on the left):

enter image description here

Your phone connects to a known cell tower and records two bars of signal. For each grid location $L_i$ you know the probability of observing two bars from this particular tower, given that the cell phone is in location $L_i$ (see the figure on the right).

Example: the highlighted cell on the left figure means that you believed there was a $0.05$ probability that the user was in the bottom right grid cell prior to observing the cell tower signal. The highlighted cell on the right figure means that you think the probability of observing two bars, given the user was in the bottom right grid cell, is $0.75$.

For each of the $16$ location positions, calculate the new probability that the user is in each location given the cell tower observation. Write a program to calculate the probabilities.

My approach of tackling this as of now: let $B$ represent the event of observing two bars. Then for the first location, the posterior probability would be

$$P(L_i\ |\ B) = \frac{P(B\ |\ L_i)P(L_i)}{\sum_{j=1}^{16}P(B\ |\ L_j)P(L_j)}$$

But suppose that I do this for the first tower and calculate $P(L_1\ |\ B)$. That'll become the new prior for location $L_1$. I'm a bit confused on how to approach, say, calculating the posterior for $L_2$. I know I'll use this equation:

$$P(L_2\ |\ B) = \frac{P(B\ |\ L_2)P(L_2)}{\sum_{j=1}^{16}P(B\ |\ L_j)P(L_j)}$$

but the denominator includes $P(L_1)$. One way is to just use the value of $P(L_1)$ given in the grid, i.e., $0.05$, but I think the "new prior" value of $P(L_1)$ (i.e. $P(L_1\ |\ B)$ that we calculated in the first step) should be used.

This is well and good, but won't the order of calculating the posterior probabilities of different locations determine the final set of values of posteriors, provided we're updating the priors in each step? Am I overthinking or does the question further need to specify in which order we're calculating the probabilities for the locations?


1 Answer 1


There may be something to the idea that computing the posterior in one cell should affect the computation for the next cell. But then, why not re-do the computation for the first cell? Also, disregarded in the statement of this problem is that results for one tower might affect results for nearby towers more than for distant ones.

My guess is that you are expected to get the posterior for each of the 16 towers in a separate computation. Contingent on correct data entry, computations in R are as follows:

L = c(5,10,5,5, 5,10,5,5, 5,5,10,5, 5,5,10,5)*.01
matrix(L, byrow=T, nrow=4)
     [,1] [,2] [,3] [,4]
[1,] 0.05 0.10 0.05 0.05
[2,] 0.05 0.10 0.05 0.05
[3,] 0.05 0.05 0.10 0.05
[4,] 0.05 0.05 0.10 0.05

B.L=c(75,95,75,5, 5,75,95,75, 1,5,75,95, 1,1,5,75)*.01
matrix(B.L, byrow=T, nrow=4)
     [,1] [,2] [,3] [,4]
[1,] 0.75 0.95 0.75 0.05
[2,] 0.05 0.75 0.95 0.75
[3,] 0.01 0.05 0.75 0.95
[4,] 0.01 0.01 0.05 0.75

D = sum(B.L*L)
L.B = B.L*L/D
[1] 1
round(matrix(L.B, byrow=T, nrow=4), 3)
      [,1]  [,2]  [,3]  [,4]
[1,] 0.074 0.188 0.074 0.005
[2,] 0.005 0.149 0.094 0.074
[3,] 0.001 0.005 0.149 0.094
[4,] 0.001 0.001 0.010 0.074

So given 2-bar information, the most likely Location is cell (1,2). This is the only cell shaded dark grey in both of your two original matrices.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.