The Beta distribution is a absolute continuous probability distribution with support \(S = [0,1]\), parameterized by two shape parameters, \(\alpha > 0\) and \(\beta > 0\).
Usage
Beta(shape1 = 1, shape2 = 1)
# S4 method for class 'Beta,numeric'
d(distr, x)
# S4 method for class 'Beta,numeric'
p(distr, x)
# S4 method for class 'Beta,numeric'
qn(distr, x)
# S4 method for class 'Beta,numeric'
r(distr, n)
# S4 method for class 'Beta'
mean(x)
# S4 method for class 'Beta'
median(x)
# S4 method for class 'Beta'
mode(x)
# S4 method for class 'Beta'
var(x)
# S4 method for class 'Beta'
sd(x)
# S4 method for class 'Beta'
skew(x)
# S4 method for class 'Beta'
kurt(x)
# S4 method for class 'Beta'
entro(x)
# S4 method for class 'Beta'
finf(x)
llbeta(x, shape1, shape2)
# S4 method for class 'Beta,numeric'
ll(distr, x)
ebeta(x, type = "mle", ...)
# S4 method for class 'Beta,numeric'
mle(distr, x, par0 = "same", method = "L-BFGS-B", lower = 1e-05, upper = Inf)
# S4 method for class 'Beta,numeric'
me(distr, x)
# S4 method for class 'Beta,numeric'
same(distr, x)
vbeta(shape1, shape2, type = "mle")
# S4 method for class 'Beta'
avar_mle(distr)
# S4 method for class 'Beta'
avar_me(distr)
# S4 method for class 'Beta'
avar_same(distr)Arguments
- shape1, shape2
numeric. The distribution parameters (positive real numbers).
- distr, x
If both arguments coexist,
distris an object of classBetaandxis a numeric vector, the sample of observations. For the moment functions that only take anxargument,xis an object of classBetainstead.- n
numeric. The sample size.
- type
character, case ignored. The estimator type (mle, me, or same).
- ...
extra arguments.
- par0, method, lower, upper
arguments passed to optim for the mle optimization.
Value
Each type of function returns a different type of object:
Distribution Functions: When supplied with one argument (
distr), thed(),p(),q(),r(),ll()functions return the density, cumulative probability, quantile, random sample generator, and log-likelihood functions, respectively. When supplied with both arguments (distrandx), they evaluate the aforementioned functions directly.Moments: Returns a numeric, either vector or matrix depending on the moment and the distribution. The
moments()function returns a list with all the available methods.Estimation: Returns a list. The estimator of the unknown parameters. Note that in distribution families like the binomial, multinomial, and negative binomial, the size is not returned, since it is considered known.
Variance: Returns a named matrix. The asymptotic covariance matrix of the estimator.
Details
The probability density function (PDF) of the Beta distribution is given by: $$ f(x; \alpha, \beta) = \frac{x^{\alpha - 1} (1 - x)^{\beta - 1}}{B(\alpha, \beta)}, \quad \alpha\in\mathbb{R}_+, \, \beta\in\mathbb{R}_+$$ for \(x \in S = [0, 1]\), where \(B(\alpha, \beta)\) is the Beta function: $$ B(\alpha, \beta) = \int_0^1 t^{\alpha - 1} (1 - t)^{\beta - 1} dt.$$
Moments
The Beta distribution has the following known moments:
Mean: \(E[X] = \frac{\alpha}{\alpha + \beta}.\)
Median: Approximated by \(\frac{\alpha - 1/3}{\alpha + \beta - 2/3}\), for \(\alpha, \beta > 1\)
Mode: \(\frac{\alpha - 1}{\alpha + \beta - 2}\), for \(\alpha, \beta > 1.\)
Variance: \(Var(X) = \frac{\alpha\beta}{(\alpha + \beta)^2 (\alpha + \beta + 1)}.\)
Skewness: \(\frac{2(\beta - \alpha)\sqrt{\alpha + \beta + 1}}{(\alpha + \beta + 2)\sqrt{\alpha\beta}}\)
Kurtosis: \(\frac{6[(\alpha - \beta)^2 (\alpha + \beta + 1) - \alpha\beta (\alpha + \beta + 2)]}{\alpha\beta (\alpha + \beta + 2) (\alpha + \beta + 3)}\)
Entropy: \(H(X) = \log B(\alpha, \beta) - (\alpha - 1)\psi(\alpha) - (\beta - 1)\psi(\beta) + (\alpha + \beta - 2)\psi(\alpha + \beta)\)
Fisher Information: The Fisher information matrix for \((\alpha, \beta)\) is given by: $$ I(\alpha, \beta) = \begin{bmatrix} \psi' (\alpha) - \psi' (\alpha + \beta) & -\psi' (\alpha + \beta) \\ -\psi' (\alpha + \beta) & \psi' (\beta) - \psi' (\alpha + \beta) \end{bmatrix} $$
Estimation
The parameters \((\alpha, \beta)\) can be estimated using:
Method of Moments: Solving for \(\alpha\) and \(\beta\) using sample mean and variance.
Maximum Likelihood Estimation (MLE): Numerical methods are typically used to maximize the log-likelihood function.
References
Tamae, H., Irie, K. & Kubokawa, T. (2020), A score-adjusted approach to closed-form estimators for the gamma and beta distributions, Japanese Journal of Statistics and Data Science 3, 543–561.
Papadatos, N. (2022), On point estimators for gamma and beta distributions, arXiv preprint arXiv:2205.10799.
Oikonomidis, I. & Trevezas, S. (2025), Moment-Type Estimators for the Dirichlet and the Multivariate Gamma Distributions, arXiv, https://arxiv.org/abs/2311.15025
Examples
# -----------------------------------------------------
# Beta Distribution Example
# -----------------------------------------------------
# Create the distribution
a <- 3 ; b <- 5
D <- Beta(a, b)
x <- c(0.3, 0.8, 0.5)
n <- 5
# Density function
df <- d(D) ; df(x) # df is a function itself
#> [1] 2.268945 0.107520 1.640625
d(D, x) # alternative way to use the function
#> [1] 2.268945 0.107520 1.640625
# Distribution function
pf <- p(D) ; pf(x)
#> [1] 0.3529305 0.9953280 0.7734375
p(D, x)
#> [1] 0.3529305 0.9953280 0.7734375
# Inverse distribution function
qf <- qn(D) ; qf(x)
#> [1] 0.2763397 0.5167578 0.3641161
qn(D, x)
#> [1] 0.2763397 0.5167578 0.3641161
# Random Generator function
rf <- r(D) ; rf(n)
#> [1] 0.14417973 0.42618777 0.04439554 0.37391245 0.50406517
r(D, n)
#> [1] 0.62327883 0.09493516 0.32794119 0.32852028 0.32141440
# List of all available moments
mom <- moments(D)
# Expectation
mean(D)
#> [1] 0.375
mom$mean
#> [1] 0.375
# Variance and Standard Deviation
var(D)
#> [1] 0.02604167
sd(D)
#> [1] 0.1613743
# Skewness and Excess Kurtosis
skew(D)
#> [1] 0.3098387
kurt(D)
#> [1] 0.04
# Entropy
entro(D)
#> [1] -0.4301508
# Fisher Information Matrix
finf(D)
#> shape1 shape2
#> shape1 0.2617971 -0.13313701
#> shape2 -0.1331370 0.08818594
# Point Estimation - The e Functions
ebeta(x, type = "mle")
#> $shape1
#> [1] 2.942949
#>
#> $shape2
#> [1] 2.535325
#>
ebeta(x, type = "me")
#> $shape1
#> [1] 2.610526
#>
#> $shape2
#> [1] 2.284211
#>
ebeta(x, type = "same")
#> $shape1
#> [1] 2.819973
#>
#> $shape2
#> [1] 2.467476
#>
mle(D, x)
#> $shape1
#> [1] 2.942949
#>
#> $shape2
#> [1] 2.535325
#>
me(D, x)
#> $shape1
#> [1] 2.610526
#>
#> $shape2
#> [1] 2.284211
#>
same(D, x)
#> $shape1
#> [1] 2.819973
#>
#> $shape2
#> [1] 2.467476
#>
e(D, x, type = "mle")
#> $shape1
#> [1] 2.942949
#>
#> $shape2
#> [1] 2.535325
#>
mle("beta", x) # the distr argument can be a character
#> $shape1
#> [1] 2.942949
#>
#> $shape2
#> [1] 2.535325
#>
# Asymptotic Variance - The v Functions
vbeta(a, b, type = "mle")
#> shape1 shape2
#> shape1 16.44844 24.83272
#> shape2 24.83272 48.83039
vbeta(a, b, type = "me")
#> shape1 shape2
#> shape1 17.64848 26.56970
#> shape2 26.56970 51.39394
vbeta(a, b, type = "same")
#> shape1 shape2
#> shape1 16.57719 24.96198
#> shape2 24.96198 49.01071
avar_mle(D)
#> shape1 shape2
#> shape1 16.44844 24.83272
#> shape2 24.83272 48.83039
avar_me(D)
#> shape1 shape2
#> shape1 17.64848 26.56970
#> shape2 26.56970 51.39394
avar_same(D)
#> shape1 shape2
#> shape1 16.57719 24.96198
#> shape2 24.96198 49.01071
avar(D, type = "mle")
#> shape1 shape2
#> shape1 16.44844 24.83272
#> shape2 24.83272 48.83039