19
votes

In R, you can generate the data from multinomial distribution using rbinom. For example, if you do

  rbinom(400, 1, 0.2) 

It generates 400 points of 0 or 1 with the probability of 0.2 that the data point is 1. So, the second argument is the number of trials, but I don't exactly know that that means. What is the number of trials? If I set this to be 1, I see the values of 0 or 1, and if I set it to be N, I see the values of 0 - N.

1

1 Answers

24
votes

The size is the total number of trials, of which size*prob are expected to be successes.

rbinom(400, size = 10, prob = 0.2)

gives the results of 400 runs of 10 coin flips each, returning the number of successes in each run.

So, rbinom(1, 10, 0.2) has the same expected value as sum(rbinom(10, 1, 0.2)).