Skip to content
Tactiverge

School/✦ Research Engineer/Week 13

Updating a belief on a grid

Instead of 'hazard or not', what if the unknown can be any number between 0 and 1? Split it into 21 slices and let the data reshape them.

About 40 min · 3 goals · Checked by automated tests

1.Why should I care?

Grid updating is Bayes' rule with many hypotheses at once. It is how a rover can track 'what fraction of sightings work today' or, in robot localisation, 'which grid cell am I in'. It also makes priors visible: you can watch the data overpower them.

  • ◇ Represent a prior over a continuous parameter on a discrete grid.
  • ◇ Update the grid with a likelihood and normalise to get the posterior.
  • ◇ Compare posterior summaries (MAP, mean, credible probability) with the MLE.

2.Discover

Pick 'Probably good'. Add one success and one failure: note the posterior mean. Now add 20 more in a 50:50 ratio. The prior's pull fades. Repeat with 'Probably poor' and check both posteriors converge.

Loading the interactive…

Can't use the interactive? Read a description instead

The grid shows 21 bars for the posterior plus prior and likelihood lines. The readout lists the data as ticks and crosses and states MAP, posterior mean, P(p > 0.5) and k/n.

3.Checkpoint: guided practice

Check what you just discovered before going on. Hints appear after a wrong answer.

Practice 1

Hypotheses p = 0.2, 0.5, 0.8 with equal prior. You observe one FAILURE. What is the posterior probability of p = 0.2?

4.Predict

With a prior that says 'the camera is probably good (≈ 0.75)', you see 1 success and 1 failure. The posterior mean will be…

Guess first. Being wrong here is how the surprise works.

5.Understand

The grid recipe

  1. Choose grid values p₁…p_m. 2. Assign prior weights π(pⱼ) summing to 1. 3. For the data, compute the likelihood L(pⱼ) = pⱼᵏ(1 − pⱼ)ⁿ⁻ᵏ. 4. Multiply: πⱼ·Lⱼ. 5. Normalise by the sum. That is the posterior: a full distribution over the unknown.

Summaries

The MAP (maximum a posteriori) is the highest bar. The posterior mean Σ pⱼ·postⱼ balances the bars. A credible probability such as P(p > 0.5 | data) is the sum of bars above 0.5: a direct answer to 'how sure are we the camera is better than a coin?'

Prior versus data

With a flat prior, the posterior is the normalised likelihood and its peak is the MLE k/n. Informative priors matter when data are scarce and fade as n grows. A grid is simple and exact for one or two parameters, but the number of cells explodes in high dimensions: that is why filters use Gaussians instead.

Explain it another way

Start with a row of 21 buckets of sand, one per possible success rate, piled according to your prior. Each observation lets some sand drain from buckets that explain it badly. Whatever sand is left, rescaled to a full load, is your new belief.

Worked example 1

Three hypotheses for p: 0.2, 0.5, 0.8, equal prior. One success observed. Posterior?

Likelihoods 0.2, 0.5, 0.8, sum 1.5. Posterior 0.133, 0.333, 0.533.

Common mix-ups

  • A Bayesian answer is just a single best number.
    ✓ It is a whole distribution; MAP, mean and credible probabilities are summaries chosen for the question.
  • Priors make Bayesian results arbitrary.
    ✓ Priors matter with little data and fade with more. Stating them openly is more honest than hiding assumptions.

6.Practice on your own

Practice, not a test. Wrong answers get a hint and another try.

Practice 2

Same three hypotheses, equal prior. You observe success then failure. What is the posterior of p = 0.5?

Practice 3

With a flat prior, where is the posterior's peak?

Practice 4

Why do robots rarely use plain grids to estimate 6-D pose (3 position + 3 orientation)?

7.Apply it

Use the grid with each of the three priors and the same 6 successes in 10 attempts. Report P(p > 0.5) for each. How many observations (at the same ratio) until all three agree within 0.05?

8.Reflect

Concepts: Bayesian estimation · Probability distributions