powered by
Draw draw Categorical distribution
rcat(n, p, replace = TRUE)
number of draws
a length-d probability vector
should the categories be replaced? If so n < p required
a draw from Categorical(p)
# NOT RUN { rcat(1, 1) ## returns 1 with probability 1 rcat(1, rep(1/6,6)) ## a dice roll # }
Run the code above in your browser using DataLab