[R] simulating outcomes - categorical distribution (?)
Gonçalo Ferraz
gferraz29 at gmail.com
Fri Jan 30 16:46:09 CET 2009
Hi,
I am simulating an event that has 15 possible outcomes and I have a
vector 'pout' that gives me the probability of each outcome -
different outcomes have different probabilities. Does anyone know a
simple way of simulating the outcome of my event?
If my event had only two possible outcomes (0/1) I would pick a
uniform random number between 0 and 1 and use it to choose between the
two possible outcomes given a certain probability of outcome 0 or
failure 1.
Now, since I have 15 possible outcomes, I guess that this should be
done with some form of a categorical distribution but I couldn't find
a function for the categorical distribution yet.
Thanks for any suggestions!
Gonçalo
More information about the R-help
mailing list