How the practitioner track works
Ten sessions, 45 minutes each, laptop open. Tonight: the conjugate update by hand and the posterior mean as a weighted average. Session 2 puts four priors on the same eighteen customers and scores each against the truth. Session 3 is the posterior as a distribution, by grid and then by sampling. Session 4 is MCMC and its diagnostics, session 5 the first PyMC 6 model, session 6 hierarchical models and partial pooling, session 7 Bayesian A/B as a decision, session 8 checking the model, session 9 saying it to executives, and session 10 a bench where all three of those are scored against a truth written into the data. The example throughout is Halloway Bakeries, a twelve-outlet chain and its voucher.
★ What you walk out with tonight. One update you can do without a computer: Beta(a, b) plus y of n is Beta(a + y, b + n - y). One reading of the prior that makes every later argument concrete: a Beta(a, b) prior is worth a + b pseudo-observations, and the posterior mean is a weighted average of the prior mean and the observed rate with weights a + b and n. And one worked case you will meet in every session that follows: Northgate, one redemption in eighteen, flat prior, posterior Beta(2, 18), mean 0.100, 89 percent interval 0.020 to 0.222, true rate 0.192.
LiveThe update is addition4 min▶
A redemption rate is a number between 0 and 1, and the natural way to hold a belief about it is a Beta distribution. Beta(a, b) has two parameters and one plain reading: it behaves exactly as if a + b customers had already been watched, a of whom redeemed. Beta(1, 1) is flat across the whole range, two pseudo-observations, one of each. Beta(12, 88) is a hundred pseudo-observations centred near 0.12.
Now the month's data arrive: y redemptions out of n vouchers. Because the Beta prior and the Binomial data fit together, the posterior is another Beta, and its parameters are the prior's with the counts added. a becomes a + y. b becomes b + n - y. Redemptions go on the first parameter, non-redemptions on the second, and that is the entire calculation. No integral, no sampler, no software. The word for a prior that does this with its likelihood is conjugate, and Beta-Binomial is the one every practitioner should be able to do in their head.
Halloway's analyst was asked for Northgate's redemption rate in a meeting that had not been scheduled to include one. Eighteen vouchers, one redeemed. Starting from Beta(1, 1), the posterior was Beta(2, 18) before the question had finished being asked, and the analyst could say, out loud, what that meant: a mean of 0.100, and an 89 percent interval running from 0.020 to 0.222. The observed 0.056 was never spoken as if it were the answer.
Self-studyThe words that will keep coming back4 min▶
- Prior. What you believed about the rate before this month's data, written as a distribution because you were not certain. Here always a Beta(a, b).
- Likelihood. What the data say on their own: y redemptions in n vouchers, a Binomial count. At Northgate, one in eighteen.
- Posterior. The blend of the two. For a Beta prior and Binomial data it is Beta(a + y, b + n - y), exactly.
- Conjugate. A prior whose posterior is in the same family, so the update is a formula rather than a computation. Beta with Binomial is the standard example.
- Pseudo-observations. a + b. The number of imaginary customers the prior is worth. The posterior mean weights the prior by this and the data by n.
- Posterior mean. (a + y) / (a + b + n). Equivalently, the weighted average of the prior mean a / (a + b) and the observed rate y / n, with weights a + b and n.
- 89 percent equal-tailed interval. The 5.5 and 94.5 percent quantiles of the posterior. The level and the kind are the tooling default now; Part 2 says why.
- Credible interval. The Bayesian interval. There is an 89 percent probability the rate lies in it, which is the sentence everybody thinks a confidence interval is. The frequentist sentence is different, and learn-statistics-with-phoebe b7 owns it.
The posterior is the prior with the counts added
8 min liveTwo lines of arithmetic, and one of them is more useful than it looks. The first line is the update itself. The second is what the update does to the mean, and it is the line that makes a prior legible: the prior votes with a + b pseudo-observations, the data vote with n, and the posterior mean is the weighted average of what each side said.
LiveNorthgate, on paper4 min▶
Northgate had 18 vouchers out and 1 came back, an observed rate of 0.056. Start from the flat prior Beta(1, 1). Add the one redemption to a: 1 + 1 = 2. Add the seventeen non-redemptions to b: 1 + 17 = 18. The posterior is Beta(2, 18). Its mean is 2 / 20 = 0.100, which is the first thing to notice: the posterior mean is not the observed rate. It sits between 0.056 and the prior's 0.500, and the weighted-average line says exactly where. The prior is worth 2 pseudo-observations, the data are worth 18, so the mean is (2 / 20) x 0.500 + (18 / 20) x 0.056, which is 0.050 + 0.050, which is 0.100.
Northgate's true rate, written into the data, is 0.192. The observed 0.056 is a long way under it, and the posterior mean of 0.100 is still under it, and neither is a mistake: one redemption in eighteen is what a true 0.192 produces at that volume reasonably often. What the posterior offers that the observed rate cannot is Part 2's object, the interval, which runs from 0.020 to 0.222 and holds the truth. Session 2 will show what happens to the same eighteen customers under three other priors, and the answer is not flattering to two of them.
Self-studyWhy the pseudo-observation reading is exact, not a metaphor3 min▶
The posterior mean is (a + y) / (a + b + n). Split the numerator into its two parts and multiply each by one: a / (a + b + n) is (a + b) / (a + b + n) times a / (a + b), and y / (a + b + n) is n / (a + b + n) times y / n. So the posterior mean is the prior mean a / (a + b) with weight (a + b) / (a + b + n), plus the observed rate y / n with weight n / (a + b + n). The two weights sum to one. The prior is worth precisely a + b observations, in the same units the data are counted in, and the word pseudo-observations is bookkeeping rather than analogy.
Two consequences follow immediately and both come back in session 2. First, a flat prior is not nothing: Beta(1, 1) is two pseudo-observations, and at Northgate they moved the mean from 0.056 to 0.100. Second, the data's weight is n / (n + a + b), which is a fraction that rises with n but never reaches one. A prior with a + b = 100 still holds one vote in ten at n = 900. Session 2 measures what that tenth costs at Westfield, Halloway's flagship, and the number is larger than most people guess.
The interval is the answer. The mean is a summary of it.
7 min liveBeta(2, 18) is a curve, not a number. The mean 0.100 is one way to summarise that curve and the observed 0.056 is another, and both of them hide how much the curve spreads. The 89 percent equal-tailed interval, 0.020 to 0.222, is the summary that keeps the spread, and it is the object every later session reports first.
LiveReading Beta(2, 18), and why it is 89 percent4 min▶
The posterior puts most of its weight below 0.15 and a long tail above it, which is what one redemption in eighteen looks like when you refuse to pretend it was more. The 89 percent equal-tailed interval cuts 5.5 percent off each tail and keeps the middle: from 0.020 to 0.222. Northgate's true rate of 0.192 sits inside it, near the top. The observed 0.056 sits on the curve's rising edge, and the mean of 0.100 sits to the right of the peak because the tail pulls it there. None of those three numbers is the answer. The curve is the answer, and the interval is the shortest honest description of it.
Every interval on every page is an 89 percent equal-tailed interval, the 5.5 and 94.5 percent quantiles, and the reason is a tooling decision rather than a theorem. ArviZ 1 changed two defaults: stats.ci_prob is now 0.89 where it was 0.94, and stats.ci_kind is now "eti", equal-tailed, where it was the highest-density interval. The maintainers' stated reason is that 0.89 gives intervals with lower variability and therefore more stable summaries. The consequence for you is that any summary a colleague ran on the new tooling is 89 percent equal-tailed unless they changed it, and any prose that still says 94 percent HDI is describing a number that is no longer being computed. Say the kind and the level every time, and match what the tool does.
Self-studyThe point estimate is a summary, and the other interval is a different sentence3 min▶
A point estimate is a choice of which single number to report from a curve. The mean is one choice; the observed rate is another; the peak of the curve, 0.056 here, is a third. They disagree at Northgate because the curve is skewed, and the disagreement is information: it says the data are thin. Reporting the interval first and the mean second keeps that information in the room. Reporting the mean alone throws it away, and reporting the observed rate alone throws away the prior too.
The credible interval says there is an 89 percent probability the rate lies between 0.020 and 0.222, given the prior and the data; a confidence interval makes a claim about the long-run behaviour of the procedure that produced it, not about this interval, and that sentence, along with the whole machinery behind it, belongs to learn-statistics-with-phoebe b7. Nothing here re-derives it. What matters tonight is that the Bayesian sentence is the one people mean when they say "the rate is probably in here", and Beta(2, 18) earns the right to say it.
The same update in scipy, and nothing else yet
22 min build-alongNo PyMC tonight, no sampler, no ArviZ. The point of a conjugate update is that a closed-form Beta answers everything, so scipy.stats.beta is the whole toolkit. Type each step, run it, and compare the printed number to the one in the comment. Session 5 will produce these same figures from a sampler, and you will want to have seen them come out of arithmetic first.
Import the one thing you need. Python 3.12 or later, scipy installed. Set the interval level once, as two quantiles, and name where the default comes from so the next reader does not have to guess.
from scipy.stats import beta CI_PROB = 0.89 # ArviZ 1 default: stats.ci_prob = 0.89 LO = (1 - CI_PROB) / 2 # 0.055 HI = 1 - LO # 0.945 # equal-tailed, which is ArviZ 1's stats.ci_kind = "eti"
Northgate, flat prior. Add the counts to the prior's parameters, then ask the resulting Beta for its mean and its two quantiles. The three printed numbers are the three you did on paper.
a, b = 1, 1 # flat prior, 2 pseudo-observations
n, y = 18, 1 # Northgate: 18 vouchers, 1 redeemed
post = beta(a + y, b + n - y) # Beta(2, 18)
print(f"posterior mean {post.mean():.3f}") # 0.100
print(f"89% interval {post.ppf(LO):.3f} to {post.ppf(HI):.3f}") # 0.020 to 0.222
Check the weighted-average line. Compute the posterior mean the second way, as prior mean times prior weight plus observed rate times data weight. It must agree to every decimal, because it is the same number.
prior_mean = a / (a + b) # 0.500
w_data = n / (a + b + n) # 18 / 20 = 0.9
w_prior = 1 - w_data # 2 / 20 = 0.1
blend = w_prior * prior_mean + w_data * (y / n)
print(f"weighted average {blend:.3f}") # 0.100
print(f"data weight {w_data:.2f}") # 0.90
Westfield, same prior. Halloway's flagship: 900 vouchers, 127 redeemed, observed 0.141. Fifty times Northgate's volume, so the two pseudo-observations barely move the mean. That is the shape session 2 will stress.
n, y = 900, 127 # Westfield: 900 vouchers, 127 redeemed
post = beta(a + y, b + n - y) # Beta(128, 774)
print(f"posterior mean {post.mean():.3f}") # 0.142
print(f"observed {y / n:.3f}") # 0.141
print(f"data weight {n / (a + b + n):.3f}") # 0.998
Write the sentence. Say Northgate's result the way it will be said in every later session: the interval first, its kind and level, then the mean as a summary. "An 89 percent equal-tailed interval of 0.020 to 0.222, posterior mean 0.100, from a flat prior and one redemption in eighteen." If someone asks for the rate, that is the rate.
Keep the quantile code. post.ppf(0.055) and post.ppf(0.945) is what every ArviZ summary is doing under the hood from now on. When session 5 hands you a DataTree of draws, the interval will be the same two quantiles of a column of numbers, and you will know it because you typed it tonight.
Three questions
A Beta(2, 14) prior sees 9 redemptions in 40 vouchers at Hillcrest. What is the posterior?
a + y = 2 + 9 = 11 and b + n - y = 14 + 40 - 9 = 45. Redemptions on the first parameter, non-redemptions on the second, and the prior stays in the sum; it is never replaced, only outvoted.
Northgate's posterior mean under the flat prior is 0.100, but the observed rate is 0.056. Why do they differ?
(2 / 20) x 0.500 + (18 / 20) x 0.056 = 0.050 + 0.050 = 0.100. A flat prior is not nothing; it is two imaginary customers, one of whom redeemed. The interval 0.020 to 0.222 is not symmetric about 0.100, so B is wrong on its own terms.
A colleague's summary reports Northgate's interval as 0.020 to 0.222 and their notebook prose calls it a 94 percent HDI. What has most likely happened?
0.020 to 0.222 is the 5.5 and 94.5 percent quantiles of Beta(2, 18), an 89 percent equal-tailed interval. ArviZ 1 made that the default, and the failure mode is exactly this: the number changed on upgrade and the sentence around it did not. Say the kind and level every time.
Before session 2
30 minRun tonight's Northgate code with three more priors in place of Beta(1, 1): Beta(2, 14), Beta(12, 88) and Beta(40, 60). For each, write down a + b, the posterior mean, the 89 percent interval, and whether 0.192 is inside it. Do not look anything up and do not change the data. Bring the four rows. Session 2 puts them on one figure and the result is the reason the track spends a whole session on priors before touching a sampler.