Chapter 2
Belief, Probability, and Exchangeability
Before computing posteriors, we must answer two foundational questions: Why should degrees of rational belief obey the mathematical axioms of probability? And why do Bayesian statisticians write down conditionally i.i.d. sampling models with a prior ? Chapter 2 of HoffPeter D. Hoff. A First Course in Bayesian Statistical Methods. Springer Texts in Statistics. Springer, New York, 2009. ISBN 978-0-387-92299-7. doi: 10.1007/978-0-387-92407-6 answers the first through belief axioms and the second through Bruno de Finetti’s representation theorem.
2.1Belief Functions and the Axioms of Probability#
Let be statements about the world, and let quantify a rational agent’s degree of belief in conditional on knowing (operationalized through betting preferences). Rationality demands three qualitative properties:Edwin T. Jaynes. Probability Theory: The Logic of Science. Cambridge University Press, Cambridge, 2003; and Leonard J. Savage. The Foundations of Statistics. Dover Publications, New York, second edition, 1972
- B1 (Boundedness): .
- B2 (Monotonicity under disjunction): .
- B3 (Sequential composition): is determined by and .
Compare these directly against Hoff’s axioms of conditional probability:Kolmogorov’s 1933 measure-theoretic axioms start from unconditional probabilities and define . Following de Finetti and Cox, Hoff takes conditional probability as primitive—reflecting the fact that every belief is held conditional on background information .
- P1: .
- P2: whenever .
- P3: .
Every probability function satisfies B1–B3. Conversely, under mild regularity conditions (strict monotonicity and smoothness of the combination functions), Cox’s theoremRichard T. Cox. Probability, Frequency and Reasonable Expectation. American Journal of Physics, 14:1–13, 1946; and Richard T. Cox. The Algebra of Probable Inference. The Johns Hopkins Press, Baltimore, 1961 shows that any consistent real-valued belief calculus is isomorphic to a probability function obeying P1–P3. Complementarily, de Finetti’s Dutch-book argument reaches the same conclusion operationally: an agent whose betting odds violate P1–P3 can be offered a finite portfolio of bets that guarantees a strict monetary loss regardless of which event actually occurs.
2.2Partitions, Bayes’ Rule, and Bayes Factors#
Definition 2.1 (Partition). A collection of events is a partition of if the events are pairwise disjoint ( for ) and exhaustive ().
If partitions the set of possible hypotheses with , and is an observed event, axioms P1–P3 immediately yield three workhorse identities:
(2.1)Dividing by cancels the normalizing constant and isolates how the data shift the relative odds of two competing hypotheses:
(2.2)The ratio is the Bayes factor: for simple (point) hypotheses, it depends solely on the sampling model and not on the prior odds .For composite hypotheses that contain free parameters (as in model selection in Chapter 9), , so the Bayes factor does depend on the within-model priors !
Example 2.2 (Worked Discrete Bayes Update: Rare-Disease Screening). Suppose a rare infection has population prevalence (so , prior odds ). A diagnostic test has sensitivity and false-positive rate .
The Bayes factor for a positive test is . Multiplying by the prior odds gives posterior odds , and hence
Even with a 95%-accurate test, a positive screen raises the probability of infection only to because false positives from the healthy majority outnumber true positives roughly to .
2.3Conditional Independence#
Definition 2.3 (Conditional Independence). Two events and are **conditionally independent given ** if
Equivalently (when ), : once is known, learning does not alter beliefs about .
For random variables and a parameter , conditional independence given means the joint density factors into a product: . When all marginal densities coincide, we write .
2.4Random Variables and Distribution Summaries#
In Bayesian inference, a random variable is simply any unknown numerical quantity—both future data and fixed but unknown parameters .
- Discrete variables have countable support and a mass function (which Hoff uniformly calls a pdf) with (e.g., Binomial and Poisson).
- Continuous variables (more precisely, those with an absolutely continuous cumulative distribution function) satisfy ; note that is a density (it can exceed and is not ), while .
Summarizing a distribution requires distinguishing mean , median , and mode . For symmetric densities such as the normal, all three coincide; for skewed distributions such as the lognormal (household income), they diverge sharply.
The variance measures average squared spread around the mean, while the -quantile yields order-based spread intervals such as the interquartile range and the 95% interval that remain well-defined even when moments do not exist.Why is the mean so prominent? Under squared-error loss , the optimal single-number guess is (differentiate with respect to ). Under absolute-error loss , the optimal guess is the median.
2.4.1Joint, Marginal, and Conditional Densities#
For any two random variables (discrete, continuous, or mixed—such as continuous parameter and discrete count ), the joint density factors in both orders:
(2.3)Crucially, knowing completely determines the joint density, whereas knowing only the marginals does not. Treating as fixed after observation, the normalizing constant does not depend on , yielding the single most useful proportionality in Bayesian computation:
(2.4)2.5Exchangeability and de Finetti’s Theorem#
Why do Bayesians assume observations are conditionally i.i.d. given , rather than marginally independent? Suppose record whether 10 survey respondents report being happy. If the were marginally independent, observing would tell us nothing about —statistical learning would be impossible! Instead, observations are marginally dependent (earlier observations teach us about the population) yet symmetric in their indices (the label “respondent 3” carries no special information).
Definition 2.4 (Exchangeability). Random variables are exchangeable if their joint density is invariant under every permutation of :
(2.5)Proposition 2.5 (Conditionally i.i.d. implies exchangeability). If and , then marginally (integrating out ), are exchangeable. Moreover, if has finite variance, then .
Proof. For any permutation of ,
because multiplication of real numbers is commutative. For the covariance, the law of total covariance gives
□
Notice what that non-negative covariance immediately implies: finite exchangeability alone does not imply a conditionally i.i.d. mixture! For example, if takes values and with probability each (sampling 2 balls without replacement from an urn with 1 red and 1 blue ball), then is exchangeable, yet —making any representation of the form (2.6) impossible. What is needed is infinite extendability: that can be viewed as the first terms of an arbitrarily long exchangeable sequence.
Theorem 2.6 (de Finetti’s Representation Theorem). Let be an infinite sequence of random variables taking values in (a Polish space). If for every the finite joint distribution of is exchangeable, then there exists a random probability distribution on (drawn from a prior measure over distributions) such that for all , conditionally on , :
(2.6)In the binary case , is completely characterized by a single scalar , and (2.6) reduces to
Bruno de Finetti. La prévision : ses lois logiques, ses sources subjectives. Annales de l’Institut Henri Poincaré, 7(1):1–68, 1937Remark 2.7 (Parametric models vs. de Finetti’s theorem). For binary data, the random distribution is a one-parameter distribution with no extra assumptions. For general real-valued data, however, Theorem 2.6 produces a random nonparametric distribution ; restricting to a finite-dimensional parametric family (such as or ) is an additional modeling approximation that must later be verified via model checking (Chapter 4).
Why is binary de Finetti true? Imagine fixing and extending the exchangeable sequence to a huge length with total count . By exchangeability, conditional on , all binary sequences are equally likely, so is a simple random sample without replacement from ones and zeros. As , sampling without replacement converges to sampling with replacement at rate —which is i.i.d.!
Even when the population size is genuinely finite (so infinite extendability does not literally hold), Diaconis and FreedmanPersi Diaconis and David Freedman. Finite Exchangeable Sequences. The Annals of Probability, 8(4):745–764, 1980 proved that the total-variation distance between an -sample from an -exchangeable sequence and a conditionally i.i.d. mixture is bounded by when has finite states, and by for arbitrary measurable spaces. Whenever , conditionally i.i.d. modeling is an extraordinarily accurate approximation.
2.6Key Takeaways & Python Check#
| Concept | Core Idea | Role in Bayesian Inference |
|---|---|---|
| Belief axioms Probability | Coherent betting preferences obey P1–P3 | Justifies probability as the calculus of uncertainty |
| Bayes factor | Isolates evidential support (depends on within-model priors for composite ) | |
| Proportionality | Lets us identify posteriors by kernel shape alone | |
| Exchangeability | Observable symmetry justifying conditionally i.i.d. models + priors |
import numpy as np
from scipy import stats
# Verify Diaconis-Freedman: hypergeometric (without replacement) vs. binomial (i.i.d.)
n, theta = 10, 0.30
k = np.arange(n + 1)
binom_pmf = stats.binom.pmf(k, n, theta)
for N in [20, 100, 1000]:
hyper_pmf = stats.hypergeom.pmf(k, M=N, n=int(N * theta), N=n)
tv_dist = 0.5 * np.sum(np.abs(hyper_pmf - binom_pmf))
print(f"N={N:4d}: TV distance = {tv_dist:.4f} (bound 2*2*n/N = {4*n/N:.4f})")2.7Modern Developments: Predictive and Anytime-Valid Inference#
2.7.1Martingale Posteriors#
A martingale posterior starts from predictive distributions for observables and obtains a distribution for without first writing down a prior and a likelihood.Beyond Hoff (2009). This material is not in Hoff’s book; it follows Fong, Holmes, and Walker, who develop the predictive reading of de Finetti’s theorem, itself much older.Edwin Fong, Chris Holmes, and Stephen G Walker. Martingale posterior distributions. Journal of the Royal Statistical Society Series B: Statistical Methodology, 85(5):1357–1391, 2023. doi: 10.1093/jrsssb/qkad005 In Theorem 2.6, the in (2.6) is the limit of the empirical distribution of an infinite sequence: given all the observables, nothing about would be unknown. So simulate the missing ones. Given a one-step predictive based on , predictive resampling draws
(2.7)and the law of given is the martingale posterior. The name reflects the coherence condition for every event : each is a martingale in , so it converges almost surely, and imagined data do not shift beliefs on average.
Why it recovers Bayes: for binary data, take the Pólya-urn predictive . This is the predictive of the model (Chapter 3), so given the simulated sequence is exchangeable and its limiting frequency has exactly the posterior law . Other predictives yield posteriors with no explicit prior.
When to use it. Use it when predictions are easier to specify than priors, or when the parametric restriction in Remark 2.7 is unwelcome; the forward simulations are independent and parallel, but truncated at a finite . With a trusted parametric model and prior, Hoff’s route is direct and exact.
2.7.2Bayes Factors as e-Values and Anytime-Valid Testing#
For a simple null hypothesis, the Bayes factor of (2.2) is also an e-value, a nonnegative statistic with null expectation at most one.Beyond Hoff (2009). This material is not in Hoff’s book; it follows Grünwald, de Heide, and Koolen and the survey of Ramdas et al. The maximal inequality it rests on is classical (Ville, 1939).Peter Grünwald, Rianne de Heide, and Wouter Koolen. Safe testing. Journal of the Royal Statistical Society Series B: Statistical Methodology, 86(5):1091–1128, 2024. doi: 10.1093/jrsssb/qkae011; and Aaditya Ramdas, Peter Grünwald, Vladimir Vovk, and Glenn Shafer. Game-Theoretic Statistics and Safe Anytime-Valid Inference. Statistical Science, 38(4):576–601, 2023. doi: 10.1214/23-STS894 Let specify a joint density , let with a proper prior fixed in advance, and set . Then for every fixed and every ,
(2.8)with equality in the first relation when wherever .
Why it holds: under , , so is a nonnegative supermartingale started at , and Ville’s inequality bounds its supremum. In Example 2.2, a positive test has and a negative one , so ; note that does not reject at level .
When is composite, averaging over a prior on it protects only on average: the expectation can exceed one at particular null values. Choosing the null mixture by reverse information projection—the mixture (or limit of mixtures) minimizing —restores the e-value property when that minimum is finite, but at a fixed sample size; unrestricted optional stopping needs a further argument.
When to use it. Use (2.8) to monitor data continuously with a frequentist guarantee. The threshold is conservative compared with a fixed- test, and unlike Hoff’s posterior odds it ignores .
2.7.3Computational & Symbolic Check#
The Python block runs the Pólya urn forward to recover its beta posterior and checks together with the bound (2.8); the Wolfram sequence proves both identities.Beyond Hoff (2009). This computational check and its Wolfram symbolic counterpart below verify the modern methods in this section and are not in Hoff’s book.
import numpy as np
from scipy import stats
from scipy.special import betaln
rng = np.random.default_rng(42)
a, b, n, s, S, M = 1, 1, 10, 7, 20_000, 2_000
ones = np.full(S, float(a + s))
for N in range(n, n + M): # Polya-urn predictive resampling
ones += rng.random(S) < ones / (a + b + N)
post = stats.beta(a + s, b + n - s)
theta = ones / (a + b + n + M)
print(f"mean {theta.mean():.3f} vs {post.mean():.3f}, sd {theta.std():.3f} vs {post.std():.3f}")
y, th0 = np.arange(n + 1), 0.3 # E_0[BF_10] summed over y = 0..n
bf = np.exp(betaln(a + y, b + n - y) - betaln(a, b) - y * np.log(th0) - (n - y) * np.log1p(-th0))
print("E_0[BF] =", np.sum(stats.binom.pmf(y, n, th0) * bf))
t, c = np.arange(1, 1001), np.cumsum(rng.random((2000, 1000)) < 0.5, axis=1)
log_bf = betaln(1 + c, 1 + t - c) + t * np.log(2)
print("Pr_0(sup BF >= 20) =", np.mean(log_bf.max(axis=1) >= np.log(20)), "<= 0.05")// Chapter 2 (modern): Polya-urn martingale, beta moments & the e-value identity
await show`Simplify[(A/T)*(A + 1)/(T + 1) + (1 - A/T)*A/(T + 1) - A/T]`const urnMom = await show`Product[(a + j)/(a + b + j), {j, 0, r - 1}]`await show`Assuming[a > 0 && b > 0 && r >= 0 && Element[r, Integers], FullSimplify[
Integrate[th^(a + r - 1)*(1 - th)^(b - 1)/Beta[a, b], {th, 0, 1}] / (${urnMom})]]`await show`Assuming[a > 0 && b > 0 && 0 < th < 1 && n >= 1 && Element[n, Integers],
Integrate[FullSimplify[Sum[Binomial[n, y]*th^y*(1 - th)^(n - y), {y, 0, n}]]
* th^(a - 1)*(1 - th)^(b - 1)/Beta[a, b], {th, 0, 1}]]`const bf10 = await show`Beta[2 + y, 3 + n - y] / (Beta[2, 3]*th0^y*(1 - th0)^(n - y))`await show`Table[Simplify[Sum[Binomial[n, y]*th0^y*(1 - th0)^(n - y)*(${bf10}), {y, 0, n}]], {n, {5, 10, 20}}]`2.8Symbolic Check in Wolfram Language#
This wolfram-ws-bridge JavaScript-mode sequence derives Bayes’ rule, the Bayes factor , the negative finite-urn covariance , and the exact finite-population hypergeometric sample-sum variance symbolically, then instantiates the screening example and exact Diaconis–Freedman total-variation distances.
// Chapter 2: Symbolic Bayes' rule, Bayes factor, and finite-population covariance & variance
const post = await show`Simplify[(s * p0) / (s * p0 + f * (1 - p0))]`await show`Simplify[((${post} / (1 - ${post})) / (p0 / (1 - p0)))]`// Finite-population without-replacement covariance Cov(Y1, Y2) < 0 and sample-sum variance
const covF = await show`FullSimplify[(kRed/nPop)*((kRed - 1)/(nPop - 1)) - (kRed/nPop)^2]`const varHyper = await show`FullSimplify[n*(kRed/nPop)*(1 - kRed/nPop) + n*(n - 1)*(${covF})]`await show`Limit[${covF} /. kRed -> th * nPop, nPop -> Infinity]`// Instantiate screening example (p0 = 1/100, s = 95/100, f = 5/100) & Diaconis-Freedman TV (N = 20, 100, 1000)
const pExact = await show`${post} /. {p0 -> 1/100, s -> 95/100, f -> 5/100}`await show`N[${pExact}]`await show`N[Table[1/2 * Sum[Abs[
Binomial[3*nPop/10, k]*Binomial[7*nPop/10, 10 - k]/Binomial[nPop, 10]
- Binomial[10, k]*(3/10)^k*(7/10)^(10 - k)], {k, 0, 10}], {nPop, {20, 100, 1000}}]]`2.9Exercises#
Exercise 2.8. Suppose a bookmaker offers even-money odds corresponding to subjective probabilities and (violating P1–P2 because ). Construct a pair of bets against this bookmaker that guarantees you a positive profit whether occurs or not.
Symbolic Solution & Instantiation
Simplify the bookmaker’s guaranteed profit when selling one unit each of and at prices .// Ex 2.1: Dutch book guaranteed profit when qF + qNotF > 1 (both outcomes F and not-F)
const profitF = await show`Simplify[(qF + qNotF) - 1]`await show`N[${profitF} /. {qF -> 6/10, qNotF -> 6/10}]`Exercise 2.9. Consider drawing balls without replacement from an urn containing red balls and blue balls, where if draw is red. Verify directly that is exchangeable and compute as a function of and . Show that for every finite with , and verify that as with .
Symbolic Solution & Instantiation
Compute symbolically for two draws without replacement from an urn of reds in .// Ex 2.2: Exchangeability & negative covariance of n = 2 draws without replacement
const p10 = await show`FullSimplify[(kRed/nPop)*((nPop - kRed)/(nPop - 1))]`const p01 = await show`FullSimplify[((nPop - kRed)/nPop)*(kRed/(nPop - 1))]`const covF = await show`FullSimplify[(kRed/nPop)*((kRed - 1)/(nPop - 1)) - (kRed/nPop)^2]`await show`{Simplify[${p10} - ${p01}], Limit[${covF} /. kRed -> th*nPop, nPop -> Infinity], N[${covF} /. {kRed -> 3, nPop -> 10}]}`Exercise 2.10. Give an example of two events and that are conditionally independent given and given , yet marginally dependent. Explain how this mirrors the behavior of observations in a Bayesian model with unknown parameter .
Symbolic Solution & Instantiation
Factor to show conditional independence given still yields marginal dependence.// Ex 2.3: Conditional independence given H and not-H still implies marginal dependence
const margDiff = await show`Factor[(h*p1*q1 + (1 - h)*p0*q0) - (h*p1 + (1 - h)*p0)*(h*q1 + (1 - h)*q0)]`await show`${margDiff} /. {h -> 1/2, p1 -> 3/4, q1 -> 3/4, p0 -> 1/4, q0 -> 1/4}`