nimble (version 0.7.0)

Multinomial: The Multinomial Distribution

Description

Density and random generation for the multinomial distribution

Usage

dmulti(x, size = sum(x), prob, log = FALSE)

rmulti(n = 1, size, prob)

Arguments

x

vector of values.

size

number of trials.

prob

vector of probabilities, internally normalized to sum to one, of same length as x

log

logical; if TRUE, probability density is returned on the log scale.

n

number of observations (only n=1 is handled currently).

Value

dmulti gives the density and rmulti generates random deviates.

Details

See Gelman et al., Appendix A or the BUGS manual for mathematical details.

References

Gelman, A., Carlin, J.B., Stern, H.S., and Rubin, D.B. (2004) Bayesian Data Analysis, 2nd ed. Chapman and Hall/CRC.

See Also

Distributions for other standard distributions

Examples

Run this code
# NOT RUN {
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 DataCamp Workspace