| rCategorical | R Documentation |
Generate random integer samples from a Categorical distribution. For a random variable x, the density function of categorical distribution is defined as
prod_{k in 1:K} p_k^{I(x=k)}
Where K is the number of unique values.
rCategorical(n, p)
n |
integer, number of samples. |
p |
numeric, probabilities. length(p)=K. |
An integer vector of length n.
dCategorical
rCategorical(n=20,p=c(1,2))