Multinomial: The Multinomial Distribution

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Density and random generation for the multinomial distribution

Usage

1
2
3
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).

Details

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

Value

dmulti gives the density and rmulti generates random deviates.

Author(s)

Christopher Paciorek

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

1
2
3
4
size <- 30
probs <- c(1/4, 1/10, 1 - 1/4 - 1/10)
x <- rmulti(1, size, probs)
dmulti(x, size, probs)

Example output

nimble version 0.6-6 is loaded.
For more information on NIMBLE and a User Manual,
please visit http://R-nimble.org.

Attaching package: 'nimble'

The following object is masked from 'package:stats':

    simulate

[1] 0.01718089

nimble documentation built on May 23, 2021, 5:07 p.m.