How can I only use the random uniform generator to create a multinomial distribution with the following probabilities: ((0.2, 0.1, 0.3, 0.4).
1
votes
2 Answers
1
votes
You can use the sample() function to sample from distributions with customized probabilities. In your case:
x <- sample(1:4, size = 100, replace = TRUE, prob = c(.2, .1, .3, .4))
This gives 100 numbers from 1 to 4 with the probabilities you provided.
sample() uses the random number generator from R, so I'm not sure if you count this as using the random uniform generator.