Solution
= Solution
Using the <expected value> of a <beta distribution>, the <posterior mean> is
$$
\boxed{\mathbb E[p\mid x]=\frac{a+n}{a+b+S}}.
$$
Equivalently, it is the weighted average
$$
\frac{a+b}{a+b+S}\frac{a}{a+b}
+\frac{S}{a+b+S}\frac{n}{S}
$$
of the <prior mean> and the <maximum-likelihood estimate> $n/S$.