Generates a random factor (i.e. a categorical random variable), given the probabilities of each category and their corresponding labels.
integer, number of random variables to generate
vector of probabilities of successes of each trial (may be constant or an rv object)
(character) labels for the categories
The length of
prob determines the number of bins.
prob will be normalized to have sum 1.
A random factor of length
Jouni Kerman email@example.com
Kerman, J. and Gelman, A. (2007). Manipulating and Summarizing Posterior Simulations Using Random Variable Objects. Statistics and Computing 17:3, 235-244.
1 2 3 4
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.