Bayesian box search problem (source code)

= Bayesian box search problem

A hidden object lies in box $i$ with posterior probability $p_i$. Searching box $i$ costs $c_i$ and, conditional on the object being there, detects it with probability $\alpha_i$. After an unsuccessful search of box $i$, <Bayes' theorem> updates the probabilities to
$$
p_i^{(i)}=\frac{(1-\alpha_i)p_i}{1-\alpha_ip_i},
\qquad
p_j^{(i)}=\frac{p_j}{1-\alpha_ip_i}\quad(j\ne i).
$$