Special | R Documentation |
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)
a |
non-negative numeric vector. |
n |
non-negative integer. |
k |
non-negative integer vector. |
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.
https://en.wikipedia.org/wiki/Beta_function#Multivariate_beta_function https://en.wikipedia.org/wiki/Multinomial_theorem#Multinomial_coefficients
See Special
for the univariate beta function and the binomial coefficient.
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.