The Beta distribution is a continuous probability distribution defined on the interval [0, 1], commonly used to model probabilities and proportions.
dist_beta(shape1, shape2)We recommend reading this documentation on pkgdown which renders math nicely. https://pkg.mitchelloharawild.com/distributional/reference/dist_beta.html
In the following, let \(X\) be a Beta random variable with parameters
shape1 = \(\alpha\) and shape2 = \(\beta\).
Support: \(x \in [0, 1]\)
Mean: \(\frac{\alpha}{\alpha + \beta}\)
Variance: \(\frac{\alpha\beta}{(\alpha + \beta)^2(\alpha + \beta + 1)}\)
Probability density function (p.d.f):
$$ f(x) = \frac{x^{\alpha - 1}(1-x)^{\beta - 1}}{B(\alpha, \beta)} = \frac{\Gamma(\alpha + \beta)}{\Gamma(\alpha)\Gamma(\beta)} x^{\alpha - 1}(1-x)^{\beta - 1} $$
where \(B(\alpha, \beta) = \frac{\Gamma(\alpha)\Gamma(\beta)}{\Gamma(\alpha + \beta)}\) is the Beta function.
Cumulative distribution function (c.d.f):
$$ F(x) = I_x(alpha, beta) = \frac{B(x; \alpha, \beta)}{B(\alpha, \beta)} $$
where \(I_x(\alpha, \beta)\) is the regularized incomplete beta function and \(B(x; \alpha, \beta) = \int_0^x t^{\alpha-1}(1-t)^{\beta-1} dt\).
Moment generating function (m.g.f):
The moment generating function does not have a simple closed form, but the moments can be calculated as:
$$ E(X^k) = \prod_{r=0}^{k-1} \frac{\alpha + r}{\alpha + \beta + r} $$
dist <- dist_beta(shape1 = c(0.5, 5, 1, 2, 2), shape2 = c(0.5, 1, 3, 2, 5))
dist
#> <distribution[5]>
#> [1] Beta(0.5, 0.5) Beta(5, 1) Beta(1, 3) Beta(2, 2) Beta(2, 5)
mean(dist)
#> [1] 0.5000000 0.8333333 0.2500000 0.5000000 0.2857143
variance(dist)
#> [1] 0.12500000 0.01984127 0.03750000 0.05000000 0.02551020
skewness(dist)
#> [1] 0.000000 -5.916080 2.581989 0.000000 5.962848
kurtosis(dist)
#> [1] -1.5000000 1.2000000 0.0952381 -0.8571429 -0.1200000
generate(dist, 10)
#> [[1]]
#> [1] 0.51272391 0.93824073 0.99515628 0.04294426 0.36260647 0.31435554
#> [7] 0.00302847 0.41149750 0.60539748 0.99916715
#>
#> [[2]]
#> [1] 0.7617427 0.7515718 0.9677268 0.8482862 0.6388981 0.8219619 0.7697629
#> [8] 0.9109772 0.9994124 0.8433937
#>
#> [[3]]
#> [1] 0.115627217 0.216302708 0.074413319 0.329727704 0.316671953 0.244305850
#> [7] 0.241259576 0.120459703 0.001220667 0.373141784
#>
#> [[4]]
#> [1] 0.5600205 0.7817342 0.3174363 0.7904692 0.4308882 0.1958695 0.2407125
#> [8] 0.7796609 0.5371046 0.6358395
#>
#> [[5]]
#> [1] 0.05643909 0.34659362 0.62582410 0.33593872 0.40339891 0.42415031
#> [7] 0.26402567 0.32176762 0.26781893 0.61462242
#>
density(dist, 2)
#> [1] 0 0 0 0 0
density(dist, 2, log = TRUE)
#> [1] -Inf -Inf -Inf -Inf -Inf
cdf(dist, 4)
#> [1] 1 1 1 1 1
quantile(dist, 0.7)
#> [1] 0.7938926 0.9311499 0.3305670 0.6367425 0.3603577