The multinomial function and its logarithm
multinomial(x) lmultinomial(x)
Numeric vector
Function multinomial() returns $${n\choose n_1,n_2,\ldots,n_k} = \frac{n!}{n_1!n_2!\cdots n_k!}$$ where \(\sum_i n_i=n\), and function lmultinomial() returns the natural logarithm of this.
multinomial()
lmultinomial()
# NOT RUN { x <- runif(10) exp(lmultinomial(x)) - multinomial(x) #should be small # }
Run the code above in your browser using DataCamp Workspace