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

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, \[\beta(a) = \Gamma(a_1)\Gamma(a_2) ... \Gamma(a_m)/\Gamma(a_1 + a_2 + \dots + a_m).\]

The functions mnchoose and lmnchoose return the multinomial coefficient and the natural logarithm of the multinomial coefficent, \[{n \choose \mathbb{k}} = \frac{n!}{k_1! k_2! \dots 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 \({n \choose \mathbb{k}}\) should be an integer), but beware this can also fail if n is large enough.

See also

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

Examples

mvbeta(c(0.5, 1, 0.5, 2))
#> [1] 0.5235988
lmvbeta(c(0.5, 1, 0.5, 2))
#> [1] -0.6470296

mnchoose(12, c(3, 3, 4, 2))
#> [1] 277200
lmnchoose(12, c(3, 3, 4, 2))
#> [1] 12.53249