Quantifying Uncertainty · Lesson 4 of 6
Bayesian Updating
~15 min
The Concept
Before this year's data arrived, your team's best guess was that 10% of Bluewater Basin's rain gauges would need recalibration in any given year, based on five years of maintenance logs. This year, 3 of the basin's 12 gauges failed calibration checks. Should your belief stay at 10%, jump to 25%, or land somewhere between?
Bayesian updating (a formal way of blending what you already believed with new evidence to form an updated belief) combines what you believed before seeing new data (your prior, meaning your starting belief) with what the new data actually shows (the likelihood, meaning how well the new evidence fits different possible truths) to produce an updated belief (the posterior, meaning your revised belief after seeing the evidence). It's a formal version of something people do informally all the time: adjusting an estimate as new evidence comes in, without either ignoring the new evidence or discarding everything you knew before.
The Analogy
Imagine you think a friend is generally on time, but then they show up late three days in a row. You do not throw out everything you knew about them, and you do not ignore the new evidence either. You land somewhere in between, updating your belief a bit toward 'maybe they are running late this week.' That blending of old belief and new evidence is exactly what Bayesian updating formalizes.
The Math (optional)
Bayes' theorem, applied to our gauge failure-rate question:
Bayes' theorem
The posterior belief about the failure rate θ, given this year's data, is proportional to how likely that data was under θ, times how plausible θ seemed beforehand.
Code (optional)
from scipy.stats import beta
# Prior: five years of maintenance logs suggested ~10% failure rate,
# encoded as a Beta(2, 18) distribution (weak prior, centered near 0.1)
prior_alpha, prior_beta = 2, 18
# This year's data: 3 failures out of 12 gauges checked
failures, checked = 3, 12
# Conjugate update: posterior is just prior + observed counts
post_alpha = prior_alpha + failures
post_beta = prior_beta + (checked - failures)
posterior = beta(post_alpha, post_beta)
print("Posterior mean failure rate:", round(posterior.mean(), 3))
print("95% credible interval:", [round(x, 3) for x in posterior.interval(0.95)])Line by line
- We encode last year's belief as a Beta distribution, a natural choice for modelling an unknown proportion.
- The Beta-Binomial conjugate update means we can update our belief with simple addition: add the observed failures and successes to the prior's parameters.
- The resulting posterior distribution gives both a best-guess failure rate and a full credible interval, not just a point estimate.
Why Real Researchers Care
This conjugate-update pattern, the mathematical shortcut that lets Bayesian updating happen via simple addition, is exactly why Beta-Binomial models are a standard tool for monitoring failure rates, defect rates, and detection probabilities in engineering and environmental monitoring alike.
Quick Check
Q1. In Bayesian updating, what does the posterior represent?
Your Goal
Using the code pattern above, would a weaker prior (say Beta(1,1), representing no prior knowledge) move the posterior mean closer to or further from the raw 3/12 = 25% observed rate? Explain why.
Hint: A weaker prior carries less 'pull' toward its own center, letting the data dominate more.
Teach It Back
Explain Bayesian updating to a friend using a non-statistical example from everyday life, forming an opinion about a new restaurant, for instance.