Rev Language Reference


fnDiscretizeBeta - Disctetize a beta distribution

Select representative values from `num_cats` discrete subdivisions of a beta distribution.

Usage

fnDiscretizeBeta(RealPos alpha, RealPos beta, Natural numCats, Bool median)

Arguments

alpha : RealPos (pass by const reference)
The alpha parameter of the beta distribution.
beta : RealPos (pass by const reference)
The beta parameter of the beta distribution
numCats : Natural (pass by value)
The number of categories.
median : Bool (pass by value)
Should we use the median or mean?
Default : FALSE

Return Type

Details

A beta distribution is defined by two shape parameters, alpha and beta. Where a parameter or prior is defined based on the beta distribution, it may be more tractable to evaluate likelihoods at a fixed number of points from the distribution. These representative points can be computed using `dnDiscretizeBeta`. In practice, these values are computed as follows: Let _n_ be the number of categories. If `median = TRUE`, the quantile function is performed at the midpoint of each category. Call this vector _q_. _q_ is then normalized by dividing against its sum, so its elements sum to one; then multiplied by a factor _n_ * _alpha) / (_alpha_ + _beta_). The computation to obtain the mean for each category, when `median = FALSE`, is more complex, making use of the incomplete beta function ( Majumder & Bhattacharjee 1973). A real-world use case is available in Wright et al. (2016), with discussion of the properties of the beta distribution. Corresponding tutorials are available at https://www.palass.org/sites/default/files/media/publications/newsletters/number_106/number_106_0.pdf and https://revbayes.github.io/tutorials/morph_tree/V2.html.

Example

# Values to represent four quadrants of a symmetric beta distribution
categories := fnDiscretizeBeta(0.2, 0.2, 4)
print(categories)

See Also