Each group has its own parameter, but the parameters are drawn from a common distribution whose spread is itself unknown. With eight schools the spread is τ: a small τ pools everything, a large τ pools nothing, and the data decide through p(τ|D). With 71 rat tumour groups the common distribution is a Beta(a, b) and empirical Bayes picks (a, b) by maximising the marginal likelihood.
Eight schools: yj ~ N(θj, σj2) with known σj, θj ~ N(μ, τ2), μ ~ N(0, 52); the τ prior is half-Cauchy(5) or flat on (0, 40]. Given τ, E[θj | y, τ] = wj E[μ | y, τ] + (1 − wj) yj, wj = σj2/(σj2 + τ2); the full-Bayes mean averages this over p(τ | D). Rats: yj ~ Bin(Nj, θj), θj ~ Beta(a, b); posterior mean (a + yj)/(a + b + Nj).
code/ch03_statistics.py (schools_tau_posterior, rats_grid_posterior, beta_eb_fit); figures 3.15 to 3.20 in the code index.