We start with a possibly biased coin which lands on head with unknown probability pp when tossed. Suppose we obtain Y=aY = a heads and Z=bZ = b tails out of a+ba + b tosses. Conditioned on p=xp = x for some x∈(0,1)x \in (0, 1), we have

Pr⁡[Y=a,Z=b∣p=x]=(a+ba)⋅xa(1−x)b. \Pr[ Y = a, Z = b \mid p = x ] = \binom{a + b}{a} \cdot x^a (1 - x)^b.

Assume further that we have equal prior of pp over [0,1][0, 1], then the posterior probability density function f(x)f(x) of pp satisfies

f(x)∝xa(1−x)b,∀x∈(0,1). f(x) \propto x^a (1 - x)^b, \qquad \forall x \in (0, 1).

This motivates the definition of Beta distribution.

Definition (Beta distribution). A random variable XX follows the Beta distribution with parameters a>0a > 0 and b>0b > 0, written as X∼B(a,b)X \sim \mathcal{B}(a, b), if its density is

f(x)=1β(a,b)⋅xa−1(1−x)b−1,0<x<1, f(x) = \frac{1}{\beta(a, b)} \cdot x^{a−1} (1 − x)^{b−1}, \qquad 0 < x < 1,

where β(a,b)\beta(a, b) is a constant.

Note that it is just a convention that we define f(x)∝xa−1(1−x)b−1f(x) \propto x^{a - 1} (1 - x)^{b - 1} for B(a,b)\mathcal{B}(a, b), instead of f(x)∝xa−1(1−x)b−1f(x) \propto x^{a - 1} (1 - x)^{b - 1}.

The fact that f(x)f(x) integrates to 11 implies that

β(a,b)=∫01xa−1(1−x)b−1 dx. \beta(a, b) = \int_0^1 x^{a−1} (1 − x)^{b−1} \, dx.

Property. Given n,k∈Nn, k \in \mathbb{N}, with k≤nk \le n,

∫01(nk)xk(1−x)n−k dx=1n+1. \int_0^1 \binom{n}{k} x^k (1 - x)^{n - k} \, dx = \frac{1}{n + 1}.

Proof.

Procedure One. Consider throwing independently and uniformly at random nn red balls and 11 blue ball onto the interval [0,1][0, 1]. Denote ZZ the number of red balls to the left of the blue ball. The integration gives the probability Pr⁡[Z=k]\Pr[ Z = k ].

Procedure Two. On the other hand, if we 1) throw n+1n + 1 red balls uniformly at random onto the interval [0,1][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

Pr⁡[Z=k]=1n+1. \Pr[ Z = k ] = \frac{1}{n + 1}.

□\square

Corollary. Given a,b∈N+a, b \in \mathbb{N}^+,

β(a,b)=∫01xa−1(1−x)b−1 dx=(a−1)!(b−1)!(a+b−1)!=Γ(a)Γ(b)Γ(a+b). \begin{aligned} \beta(a, b) = \int_0^1 x^{a - 1} (1 - x)^{b - 1} \, dx = \frac{(a - 1)! (b - 1)!}{(a + b - 1)!} = \frac{\Gamma(a) \Gamma(b)}{ \Gamma(a + b) }. \end{aligned}

Remark: the result can be generalized to a,b>0a, b > 0.

Property.

E[X]=aa+b. \mathbb{E}[X] = \frac{a}{a + b}.

Proof.

E[X]=1β(a,b)⋅∫01xa(1−x)b−1 dx=β(a+1,b)β(a,b)=Γ(a+1)Γ(b)Γ(a+b+1)⋅Γ(a+b)Γ(a)Γ(b)=aa+b. \begin{aligned} \mathbb{E}[X] &= \frac{1}{\beta(a, b)} \cdot \int_0^1 x^{a} (1 − x)^{b−1} \, dx \\ &= \frac{\beta(a + 1, b)}{\beta(a, b)} \\ &= \frac{\Gamma(a + 1) \Gamma(b)}{ \Gamma(a + b + 1)} \cdot \frac{ \Gamma(a + b) }{\Gamma(a) \Gamma(b)} \\ &= \frac{a}{a + b}. \end{aligned}

□\square

Property.

Var[X]=ab(a+b+1)(a+b)2. \mathbb{Var}[X] = \frac{ ab }{(a + b + 1)(a + b)^2}.

Proof.

E[X2]=1β(a,b)⋅∫01xa+1(1−x)b−1 dx=β(a+2,b)β(a,b)=Γ(a+2)Γ(b)Γ(a+b+2)⋅Γ(a+b)Γ(a)Γ(b)=(a+1)a(a+b+1)(a+b). \begin{aligned} \mathbb{E}[X^2] &= \frac{1}{\beta(a, b)} \cdot \int_0^1 x^{a + 1} (1 − x)^{b−1} \, dx \\ &= \frac{\beta(a + 2, b)}{\beta(a, b)} \\ &= \frac{\Gamma(a + 2) \Gamma(b)}{ \Gamma(a + b + 2)} \cdot \frac{ \Gamma(a + b) }{\Gamma(a) \Gamma(b)} \\ &= \frac{(a + 1) a}{(a + b + 1)(a + b)}. \end{aligned}

Hence,

Var[X]=E[X2]−(E[X])2=(a+1)a(a+b+1)(a+b)−(aa+b)2=(a+1)a(a+b)−a2(a+b+1)(a+b+1)(a+b)2=a⋅a2+ab+a+b−a2−ab−a(a+b+1)(a+b)2=ab(a+b+1)(a+b)2. \begin{aligned} \mathbb{Var}[X] &= \mathbb{E}[X^2] - \big( \mathbb{E}[X] \big)^2 \\ &= \frac{(a + 1) a}{(a + b + 1)(a + b)} - \left( \frac{a}{a + b} \right)^2 \\ &= \frac{(a + 1) a (a + b) - a^2 (a + b + 1) }{(a + b + 1)(a + b)^2} \\ &= a \cdot \frac{ a^2 + ab + a + b - a^2 - a b - a }{(a + b + 1)(a + b)^2} \\ &= \frac{ ab }{(a + b + 1)(a + b)^2}. \end{aligned}

□\square

Property (Beta Binomial Conjugacy). Let n∈N+n \in \mathbb{N}^+. Suppose that X∼B(a,b)X \sim \mathcal{B}(a, b), and Z∼Bin(n,X)Z \sim \textnormal{Bin}(n, X), then for each k∈N+k \in \mathbb{N}^+, k≤nk \le n, then the posterior probability distribution of XX equals B(a+k,b+n−k)\mathcal{B}(a + k, b + n - k).

Proof. Let f(x∣Z=k)f(x \mid Z = k) be the posterior density function. Then for each x∈[0,1]x \in [0, 1],

f(x∣Z=k)=(nk)xk(1−x)n−kf(x)Pr⁡[Z=k]=(nk)xa+k−1(1−x)b+n−k−1Pr⁡[Z=k]⋅β(a,b)∝xa+k−1(1−x)b+n−k−1. \begin{aligned} f(x \mid Z = k) &= \frac{ \binom{n}{k} x^k (1 - x)^{n - k} f(x) }{ \Pr[ Z = k ] } \\ &= \frac{ \binom{n}{k} x^{a + k - 1} (1 - x)^{b + n - k - 1} }{ \Pr[ Z = k ] \cdot \beta(a, b) } \\ &\propto x^{a + k - 1} (1 - x)^{b + n - k - 1}. \end{aligned}

The last ''∝\propto'' holds since Pr⁡[Z=k]\Pr[ Z = k ] is a constant.

□\square

Reference

[1] J. Blitzstein and J. Hwang, Introduction to Probability.