We start with a possibly biased coin which lands on head with unknown probability p when tossed.
Suppose we obtain Y=a heads and Z=b tails out of a+b tosses.
Conditioned on p=x for some x∈(0,1), we have
Pr[Y=a,Z=b∣p=x]=(aa+b)⋅xa(1−x)b.
Assume further that we have equal prior of p over [0,1], then the posterior probability density function f(x) of p satisfies
f(x)∝xa(1−x)b,∀x∈(0,1).
This motivates the definition of Beta distribution.
Definition (Beta distribution). A random variable X follows the Beta distribution with parameters a>0 and b>0, written as X∼B(a,b), if its density is
f(x)=β(a,b)1⋅xa−1(1−x)b−1,0<x<1,
where β(a,b) is a constant.
Note that it is just a convention that we define f(x)∝xa−1(1−x)b−1 for B(a,b), instead of f(x)∝xa−1(1−x)b−1.
The fact that f(x) integrates to 1 implies that
β(a,b)=∫01xa−1(1−x)b−1dx.
Property. Given n,k∈N, with k≤n,
∫01(kn)xk(1−x)n−kdx=n+11.
Proof.
Procedure One.
Consider throwing independently and uniformly at random n red balls and 1 blue ball onto the interval [0,1].
Denote Z the number of red balls to the left of the blue ball.
The integration gives the probability Pr[Z=k].
Procedure Two.
On the other hand, if we 1) throw n+1 red balls uniformly at random onto the interval [0,1]; 2) pick one red ball at random; 3) and replace it by a blue one, then the number of red balls to the left of the blue one follows the same distribution as in procedure one.
Hence
Property (Beta Binomial Conjugacy). Let n∈N+.
Suppose that X∼B(a,b), and Z∼Bin(n,X), then for each k∈N+, k≤n, then the posterior probability distribution of X equals B(a+k,b+n−k).
Proof.
Let f(x∣Z=k) be the posterior density function.
Then for each x∈[0,1],