lmbeta: Natural Logarithm of the Multivariate Beta Function

Description Usage Arguments Details Value References See Also Examples

View source: R/utils.R

Description

\loadmathjax

Underflow-robust implementation of the natural logarithm of the multivariate Beta function.

Usage

1
lmbeta(x)

Arguments

x

A numeric vector of non-negative values.

Details

Consider the numeric vector \mjeqnx = (x_1, ..., x_k)x = (x_1, ..., x_k) with \mjeqnx_i > 0 \, \forall i \in \lbrace 1, ..., k \rbracex_i > 0 for all i in {1, ..., k }. The multivariate Beta function is defined as:

\mjdeqn\operatorname

B(x) = \prod_i=1^k \Gamma (x_i) \Big/ \Gamma \left(\sum_i=1^k x_i \right)B(x) = product_i=1^k Gamma(x_i) / Gamma(sum_i=1^k x_i)

where \mjeqn\GammaGamma is the Gamma function. Taking the natural logarithm of both sides in the latter equation we obtain:

\mjdeqn\operatorname

log \operatornameB(x) = \sum_i=1^k\operatornamelog \, \Gamma(x_i) - \operatornamelog \, \Gamma \left(\sum_i = 1^kx_i\right)log B(x) = sum_i=1^klogGamma(x_i) - logGamma(sum_i = 1^k x_i)

With this formula we can take advantage of the underflow-robust lgamma function. Note that \mjeqn\operatornameB(x)B(x) is only defined in \mjeqn\ReR if all elements of x are greater than zero and is infinite if any element of x is equal to zero \insertCitebecker1972polya.

Value

If all elements of x are greater than zero then lmbeta returns a numeric vector of length 1. If any element of x is equal to zero then lmbeta returns inf.

References

\insertAllCited

See Also

Examples

1
2
3
4
5
lmbeta(c(1, 1)) # same as lbeta(1,1)
lmbeta(c(1, 1, 1))
lmbeta(c(1, 2, 4))
lmbeta(rep(0.5, 10))
lmbeta(1:5)

pedro-teles-fonseca/polya documentation built on Jan. 30, 2021, 6:47 p.m.