powered by
Density and random generation for the categorical distribution
dcat(x, prob, log = FALSE)rcat(n = 1, prob)
rcat(n = 1, prob)
dcat gives the density and rcat generates random deviates.
dcat
rcat
non-negative integer-value numeric value.
vector of probabilities, internally normalized to sum to one.
logical; if TRUE, probability density is returned on the log scale.
number of observations.
Christopher Paciorek
See the BUGS manual for mathematical details.
Distributions for other standard distributions
probs <- c(1/4, 1/10, 1 - 1/4 - 1/10) x <- rcat(n = 30, probs) dcat(x, probs)
Run the code above in your browser using DataLab