Special: (More) Special Functions of Mathematics

SpecialR Documentation

(More) Special Functions of Mathematics

Description

\loadmathjax

Special mathematical functions not included in base R, specifically the multivariate form of the beta function and the multinomial coefficient.

Usage

mvbeta(a)
lmvbeta(a)

mnchoose(n, k)
lmnchoose(n, k)

Arguments

a

non-negative numeric vector.

n

non-negative integer.

k

non-negative integer vector.

Details

The functions mvbeta and lmvbeta return the multivariate beta function and the natural logarithm of the multivariate beta function, \mjdeqn\beta(a) = \Gamma(a_1)\Gamma(a_2) ... \Gamma(a_m)/\Gamma(a_1 + a_2 + ... + a_m).

The functions mnchoose and lmnchoose return the multinomial coefficient and the natural logarithm of the multinomial coefficent, \mjdeqnn \choose \mathbbk = \fracn!k_1! k_2! ... k_m!.

These calculations are difficult (or impossible) for large n, so it is calculated in log space, which is much easier. If the logarithm is not desired, the result is exponentiated (and rounded, because \mjeqnn \choose \mathbbk should be an integer), but beware this can also fail if n is large enough.

References

https://en.wikipedia.org/wiki/Beta_function#Multivariate_beta_function https://en.wikipedia.org/wiki/Multinomial_theorem#Multinomial_coefficients

See Also

See Special for the univariate beta function and the binomial coefficient.

Examples

mvbeta(c(0.5, 1, 0.5, 2))
lmvbeta(c(0.5, 1, 0.5, 2))

mnchoose(12, c(3, 3, 4, 2))
lmnchoose(12, c(3, 3, 4, 2))


ctgrubb/lemur.pack documentation built on May 7, 2023, 4:13 a.m.