# Beta

## The Beta Distribution

• The Beta Distribution can be used for a continuous random variable that can only take values between 0 and 1.
• Can be used to describe the amount of time an event or project will take to complete, if it must take place within a specified interval.

## Probability Density Function

• The leading term (with the Gamma functions) is a constant that ensures the area under the pdf curve = 1.
• R code: dbeta(p,alpha,beta), where the sum alpha+beta is regarded as the "sample size" and alpha/(alpha+beta) is the population mean.
• Another useful parameterization is a = alpha/(alpha+beta) and b = 1/sqrt(alpha+beta)
• alpha = a/b^2
• beta = (1-a)/b^2

## Cumulative Distribution Function

• where Bx(α,β) is the incomplete beta function and Ix(α,β) is the regularized incomplete beta function.
• R code: pbeta(q, alpha, beta)

## Generating Random Variables

> rbeta(10,5,8)

``` 0.28396857 0.29257510 0.43823168 0.46036009 0.31662962 0.31494870
 0.31709740 0.35495964 0.39718446 0.07957405
```

## Parameter Estimation

### Bayesian

Two cases are described below. In the first, we are given a sample drawn directly from a beta-distributed population. In the second, rathe than observing the sampled probabilities directly, we're given the results of repeated Bernoulli trials (i.e., Binomial trials, with perhaps-different orders (Ns)) for each unobserved probability.

#### Data = Beta-Distributed Probabilities = c(p1, p2, ...pn)

The likelihood function is simply the product of beta densities.

• L(data|alpha,beta) = dbeta(p1,alpha,beta)*dbeta(p2,alpha,beta)*...*dbeta(pn,alpha,beta)

#### Data are Binomial = list(c(K1, K2, ...Kn), c(N1, N2, ...Nn))

The likelihood function can be expressed as a product of gamma functions divided by another product of gamma functions.

• L(K1|N1,alpha,beta) = ln(Gamma(alpha+beta))+ln(Gamma(alpha+K1))+ln(Gamma(beta+N1-K1))-ln(Gamma(alpha+beta+N))-ln(Gamma(alpha))-ln(Gamma(beta))
• L(data|alpah,beta) = L(K1|N1,alpha,beta)*L(K2|N2,alpha,beta)*...*L(Kn|Nn,alpha,beta)

## Related Distributions

• Continuous Uniform - Can be thought of as a special case of Beta
• Binomial - Beta is a conjugate prior