Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Multinomial

Multinomial distribution


Description

Probability mass function and random generation for the multinomial distribution.

Usage

dmnom(x, size, prob, log = FALSE)

rmnom(n, size, prob)

Arguments

x

k-column matrix of quantiles.

size

numeric vector; number of trials (zero or more).

prob

k-column numeric matrix; probability of success on each trial.

log

logical; if TRUE, probabilities p are given as log(p).

n

number of observations. If length(n) > 1, the length is taken to be the number required.

Details

Probability mass function

f(x) = n!/prod(x[i]!) * prod(p[i]^x[i])

References

Gentle, J.E. (2006). Random number generation and Monte Carlo methods. Springer.

See Also

Examples

# 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)))

extraDistr

Additional Univariate and Multivariate Distributions

v1.9.1
GPL-2
Authors
Tymoteusz Wolodzko
Initial release
2020-08-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.