Multinomial | R Documentation |
Probability mass function and random generation for the multinomial distribution.
dmnom(x, size, prob, log = FALSE)
rmnom(n, size, prob)
x |
|
size |
numeric vector; number of trials (zero or more). |
prob |
|
log |
logical; if TRUE, probabilities p are given as log(p). |
n |
number of observations. If |
Probability mass function
f(x) = \frac{n!}{\prod_{i=1}^k x_i} \prod_{i=1}^k p_i^{x_i}
Gentle, J.E. (2006). Random number generation and Monte Carlo methods. Springer.
Binomial
, Multinomial
# Generating 10 random draws from multinomial distribution
# parametrized using a vector
(x <- rmnom(10, 3, c(1/3, 1/3, 1/3)))
# Results are consistent with dmultinom() from stats:
all.equal(dmultinom(x[1,], 3, c(1/3, 1/3, 1/3)),
dmnom(x[1, , drop = FALSE], 3, c(1/3, 1/3, 1/3)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.