Calculating these probabilities is an application of Bayes' Theorem . But, rather than just state Bayes' Theorem, let go over the procedure to obtain Bayes' theorem in order to see what that means in this context.

If we measure a spike from the neuron, then the probability that an event from the second column of the above contingency table is . That's because, if we recorded that spike, we know that we had to be in the second column of the contingency table, so the total probability of that column must be 1.

Given that we know that we are in the second column (i.e., that we measured that a spike occurred), we want to know likelihood we were in the first row versus in the second row (i.e., that the rat was in room 1 rather than room 2). To answer this question, we just need to rescale the probabilities so that the total probability for second column is 1. In other words, we need to divide the values in the second column by its total $P(R=1) = $ .

What you calculated in that rescaled table were the conditional probabilities . Without realizing it, you used Bayes' Theorem.

Recall that the contingency contained values like $P(R=1,X=1) = P(R=1 \,|\, X=1) P(X=1)$. Then, when dividing by $P(R=1)$, you calculated Bayes' theorem as

(The division by $P(R=1)$ is the rescaling due to the fact we are only considering cases where the neuron spiked. You could think of estimating the probability $P(X=1 \,|\, R=1)$ by counting all the times the rat was in room 1 with the neuron spiking and dividing, i.e., rescaling, by the total number of times that the neuron spiked.)

These conditional probabilities are exactly the results we were looking for: the posterior distribution of the rat's location given that we read the rat's mind and measured a spike. If we denote this distribution of $X$, conditioned on $R=1$, as $f_{X|R=1}(x)$, we can express our results as
$f_{X|R=1}(1) = $
$f_{X|R=1}(2) = $

Plot the posterior distribution of $X$.

Feedback from applet
Point heights:

Bayes' Theorem shows how we calculate the posterior distribution from the prior distribution. We simply need to know how the spiking probability of a neuron depends on the rat's location (which is easy to determine experimentally). Armed with this tool, when we measure a spike from the neuron, we can read the rat's mind to determine these probabilities for being in the different rooms.

decode_linear_track_two_neurons.m