Solution (source code)

= Solution

With the uniform prior, the <binomial likelihood> gives the <Beta distribution> posterior $\operatorname{Beta}(s+1,n-s+1)$. Under <squared-error loss>, the <Bayes estimator> is the posterior mean:
$$
\boxed{\hat p_G=\frac{s+1}{n+2}.}
$$

The production manager's prior gives posterior density proportional to $p^{s+1}(1-p)^{n-s}$. Minimizing $\mathbb E[(1-p)(\hat p-p)^2\mid X=s]$ gives the weighted posterior mean
$$
\hat p_P=\frac{\mathbb E[p(1-p)\mid X=s]}{\mathbb E[1-p\mid X=s]}
=\boxed{\frac{s+2}{n+4}},
$$
using the supplied <beta function>. Cross multiplication shows $\hat p_P>\hat p_G$ exactly when $n>2s$, so it is greater unless \b[$s\geq n/2$].