A beta prior for a proportion meets binomial data, or a gamma prior for a Poisson rate meets counts, and the posterior is again a beta or a gamma law with the data added to the prior's parameters. The top panel shows the prior (dashed), the likelihood rescaled to a density (dotted) and the posterior (solid). Which single number to report depends on the loss: the posterior mean for squared error, the median for absolute error, and, for Max's inventory loss in which a lost sale costs c and an unsold copy d, the quantile at level c/(c+d). The bottom panel draws that expected loss and its minimum.
Beta(r, s) prior and k successes in n trials give Beta(k+r, n−k+s); Gamma(s, μ) prior (rate μ) and a total w of n Poisson counts give Gamma(w+s, μ+n). Quantiles are found by bisection on the exact cdf; the expected loss is integrated numerically over the posterior. A cost share of 1/2 gives the median.
code/ch05_estimation.py (beta_binomial_update, gamma_poisson_update, bayes_estimates, asymmetric_risk).