In here I will create short intro for beta and gamma distributions two very important distributions form different univariate distributions.

## Beta distribution

The beta distribution has support over the interval [0,1] and is defined as follows: $\operatorname{Beta}(x \mid a, b)=\frac{1}{B(a, b)} x^{a-1}(1-x)^{b-1}$ Where $B(p, q)$ is the beta function: $B(a, b) = \frac{\Gamma(a) \Gamma(b)}{\Gamma(a+b)}$

Beta function $B$ can also be defined as:

$B(a, b)=\int_{0}^{1} u^{a-1}(1-u)^{b-1} d u \quad a, b \in(0, \infty)$

Parameters:

• $a$ left parameter
• $b$ right parameter

If $a, b \in(0, \infty)$ then $B(a, b)=\frac{\Gamma(a) \Gamma(b)}{\Gamma(a+b)}$

Special case: Incomplete beta function:

$B(x ; a, b)=\int_{0}^{x} u^{a-1}(1-u)^{b-1} d u, \quad x \in(0,1) ; a, b \in(0, \infty)$

When $x=1$, this is complete beta function.

Beta distribution (PDF):

To distinguish $B(a,b)$ is not same as $Beta(a, b) =B(x \mid a,b)$

$B(x \mid a,b)=\frac{1}{B(a, b)} x^{a-1}(1-x)^{b-1}, \quad x \in(0,1)$

where parameters $a$ and $b$ need to be positive.

The mean and variance of beta distribution:

$\mathbb{E}[X]=\Large \frac{a}{a+b}$

$\mathbb{V}[X]=\Large \frac{a b}{(a+b)^{2}(a+b-1)}$

$\operatorname{Mode}[X]=\Large \frac{a-1}{a+b-2}$

Beta distribution is conjugate to the Bernoulli likelihood.

$p(X \mid \theta)=\theta^{N_{1}}(1-\theta)^{N_{0}}$ $p(\theta)=B(\theta \mid a, b) \propto \theta^{a-1}(1-\theta)^{b-1}$ $p(\theta \mid X) \propto p(X \mid \theta) p(\theta)$ $p(\theta \mid X) \propto \theta^{N_{1}}(1-\theta)^{N_{0}} \cdot \theta^{a-1}(1-\theta)^{b-1}$ $p(\theta \mid X) \propto \theta^{N_{1}+a-1}(1-\theta)^{N_{0}+b-1}$ $p(\theta \mid X)=B\left(N_{1}+a, N_{0}+b\right)$

Example: Percentage of PDF inside interval

Let’s calculate $Beta(3,1)$ inside $[0,0.5]$ interval using R code.

The beta function in R can be implemented using the beta(a,b) however to integrate the pdf we need dbeta function.

## Appendix

Exponential family of distribution is huge, among many others, exponential families includes:

• normal
• exponential
• beta
• gamma
• chi-squared
• geometric
• etc.