Observe x successes in n trials and put a Beta(α, β) prior on p; the posterior is Beta(α + x, β + n − x), skewed when x is near 0 or n. Theorem 12.7 says: report the action a with the smallest posterior expected loss. Under squared loss that is the posterior mean, under absolute loss the posterior median. A literal zero-one loss is useless for a continuous parameter (every action is wrong with probability 1), so the demo uses the window loss 1{|p − a| > ε}: its Bayes action is the centre of the most probable window, and it slides to the posterior mode as ε → 0. The table averages over all possible data sets: each rule wins under its own loss.
Everything is exact. Posterior expected losses: squared V + (μ − a)²; absolute a(2Ia(A, B) − 1) + μ(1 − 2Ia(A + 1, B)); window 1 − P(|p − a| ≤ ε), with I the regularised incomplete beta function. Bayes risks sum the posterior expected loss over the Beta-Binomial distribution of x (Theorem 12.7). In panel (b) each curve is rescaled to run from 0 to 1.
code/ch12_decision_theory.py (beta_summary, post_loss, bayes_risk_table; Figure 12.S2).