The Bayesian Cars

After a break, we are back with a Bayesian problem. It is taken from the Penn State site and combines the Bayes rule with Poisson probabilities.

Amy thinks the average number of cars passing an intersection is 3 in a given period, whereas Becky thinks it’s 5. On a random day of data collection, they observed seven cars. What are the probabilities for each of their hypotheses?

\\ P(\lambda = 3|X = 7) = \frac{P(X = 7 | \lambda = 3) * P(\lambda = 3)}{P(X = 7 | \lambda = 3) * P(\lambda = 3) + P(X = 7 | \lambda = 5) * P(\lambda = 5)}

Let’s give equal prior probabilities for both (P(lambda = 3) P(lambda = 5) = 0.5). P(X = 7 | lambda = 3) is given by the Poisson probability density function:

dpois(7, 3)
dpois(7, 5)
0.022
0.105

\\ P(\lambda = 3|X = 7) = \frac{0.022 * 0.5}{0.022 * 0.5 + 0.105 * 0.5} = 0.173

\\ P(\lambda = 5|X = 7) = \frac{0.105 * 0.5}{0.105 * 0.5 + 0.022 * 0.5} = 0.826