Chapter 3 notes. Task: the prior over the head probability \(r\) is flat, \(p(r)=1\) for \(0<r<1\). Find the posterior \(p(r\mid y)\) after observing \(y\) heads in \(N\) tosses.
The denominator \(p(y)=\int p(y\mid r)p(r)\,dr\) has \(r\) integrated out, so it does not depend on \(r\). As a function of \(r\), the posterior has the shape of likelihood times prior, and the constant can be recovered at the end.
As a probability, this formula is a distribution over the count \(y\) for a known \(r\). As a likelihood, it asks how well each possible \(r\) explains the data you saw. It is not a density over \(r\) and does not integrate to 1.
Drop everything that does not contain \(r\). The binomial coefficient \(\binom{N}{y}\) goes into the constant:
\[p(r\mid y) \;\propto\; r^{y}(1-r)^{N-y}.\]A beta density is proportional to \(r^{a-1}(1-r)^{b-1}\). Matching exponents:
\[a-1 = y \;\Rightarrow\; a = y+1, \qquad b-1 = N-y \;\Rightarrow\; b = N-y+1.\]The shape is that of a beta density, so the normalising constant must be the beta one, \(\Gamma(a+b)/(\Gamma(a)\Gamma(b))\) with \(a+b=N+2\). There is no need to compute \(p(y)\):
\[\boxed{\;p(r\mid y) = \frac{\Gamma(N+2)}{\Gamma(y+1)\,\Gamma(N-y+1)}\; r^{y}(1-r)^{N-y}\;}\]This is a \(\mathrm{Beta}(y+1,\;N-y+1)\) density.
The flat line is the prior. One head tilts the density toward large \(r\) but leaves it wide. With more tosses the density narrows around the observed fraction of heads. The more data, the less the flat prior matters.