Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Source

Perception is inference: given measurements, what is the state? Bayes’ rule answers this by combining what we believed beforehand with how well each state explains the evidence.

Bayes’ rule

Applying the product rule both ways, P(x,z)=P(zx)P(x)=P(xz)P(z)P(x, z) = P(z \mid x)P(x) = P(x \mid z)P(z), and solving for the quantity we want gives

P(xz)posterior=P(zx)likelihood  P(x)priorP(z)evidence    P(zx)P(x)\underbrace{P(x \mid z)}_{\text{posterior}} = \frac{\overbrace{P(z \mid x)}^{\text{likelihood}}\;\overbrace{P(x)}^{\text{prior}}}{\underbrace{P(z)}_{\text{evidence}}} \;\propto\; P(z \mid x)\,P(x)

The evidence P(z)=xP(zx)P(x)P(z) = \sum_x P(z\mid x)P(x) does not depend on xx, so in practice we multiply prior by likelihood and then normalize so the result sums to one.

Where am I in the corridor?

A robot is somewhere in a corridor divided into 20 cells. Some cells have doors. Its door sensor has a true-positive rate of 0.85 and a false-positive rate of 0.15. The robot does not move in this example; it simply takes readings while standing in place.

<Figure size 770x660 with 5 Axes>

Each “door seen” reading shifts probability toward the door cells. Because the robot is not moving, however, it can never tell which door it is standing at, and the belief stays split across four peaks. Resolving this ambiguity requires motion plus sensing, which is the Bayes filter we build in Chapter 6.

MAP and posterior mean

A belief is a whole distribution, but we often need a single answer. Two common choices:

x^MAP=argmaxxP(xz),x^MMSE=E[xz]=xxP(xz)\hat{x}_{\text{MAP}} = \arg\max_x P(x \mid z), \qquad \hat{x}_{\text{MMSE}} = \mathbb{E}[x \mid z] = \sum_x x\,P(x \mid z)

With a multimodal belief like the one above, the posterior mean can land between doors, where the robot certainly is not. That is a warning that summarizing a belief by one number throws information away.

MAP cell: 2 | posterior mean: 8.64

Continuous Bayes: fusing two Gaussians

When both prior and likelihood are Gaussian, the posterior is also Gaussian, and the update has a closed form. For a prior N(μ0,σ02)\mathcal{N}(\mu_0, \sigma_0^2) and a measurement zz with noise σz2\sigma_z^2:

μ1=σz2μ0+σ02zσ02+σz2,σ12=σ02σz2σ02+σz2\mu_1 = \frac{\sigma_z^2\,\mu_0 + \sigma_0^2\,z}{\sigma_0^2 + \sigma_z^2}, \qquad \sigma_1^2 = \frac{\sigma_0^2\,\sigma_z^2}{\sigma_0^2 + \sigma_z^2}

The posterior mean is a weighted average that trusts the less noisy source more, and the posterior variance is always smaller than either input. This one equation is the heart of the Kalman filter in Chapter 7.

<Figure size 770x396 with 1 Axes>