powered by
Density and random generation for the multinomial distribution
dmulti(x, size = sum(x), prob, log = FALSE)rmulti(n = 1, size, prob)
rmulti(n = 1, size, prob)
dmulti gives the density and rmulti generates random deviates.
dmulti
rmulti
vector of values.
number of trials.
vector of probabilities, internally normalized to sum to one, of same length as x
x
logical; if TRUE, probability density is returned on the log scale.
number of observations (only n=1 is handled currently).
n=1
Christopher Paciorek
See Gelman et al., Appendix A or the BUGS manual for mathematical details.
Gelman, A., Carlin, J.B., Stern, H.S., and Rubin, D.B. (2004) Bayesian Data Analysis, 2nd ed. Chapman and Hall/CRC.
Distributions for other standard distributions
size <- 30 probs <- c(1/4, 1/10, 1 - 1/4 - 1/10) x <- rmulti(1, size, probs) dmulti(x, size, probs)
Run the code above in your browser using DataLab