Lite / Independent Engineering Research / 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.
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.
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…
- Exactly 0.5
- Above 0.5, pulled by the prior
- Below 0.5
- Exactly 0.75
Guess first, then reveal
Two observations barely move a confident prior. The likelihood peaks at 0.5, the prior at 0.75, and the posterior sits between, nearer the prior until much more data arrive.
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.
What the interactive shows (text version)
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.
Understand
The grid recipe
- 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
Intuitive
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.
Technical
With a Beta(a, b) prior the posterior is Beta(a + k, b + n − k) exactly (conjugacy). The grid approximates this for any prior shape, including ones with no formula.
Mathematical
Flat prior, k = 3, n = 4: posterior ∝ p³(1 − p). Continuous posterior mean (k + 1)/(n + 2) = 4/6 ≈ 0.667; MAP = k/n = 0.75. The 21-point grid reproduces both closely.
Applied
Markov localisation for robots uses exactly this, with the grid over positions: predict by shifting the belief with odometry, update by multiplying by the sensor likelihood. The term project's 'where is the rover?' question can be answered that way too.
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.
Practice
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
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?
Reflect
What prior would you choose for a brand-new camera you have never tested, and why?
Write your answer on paper or in your own notes. Lite never stores what you write.