Manoj
Manoj

Reputation: 275

How can i generate random number with binomial distribution?

I wanted to simulated number of vegetarian student in a particular population. A particular research paper has given an idea about a specific distribution. I like to test the idea using true random numbers. Paper suggest that 6% of a student of a given population is considered as vegetarian.

So I wanted to generate 40 random numbers with probability 6% which follows binomial distribution in Excel. I can generate numbers using a normal distribution. But I can't figure out how to generate them to follow binomial distribution, in this case I think binomial is more appropriate.

Thanks

Upvotes: 2

Views: 8841

Answers (2)

Harshil S Patel
Harshil S Patel

Reputation: 56

Use the following function, remember Bernoulli is a special case of binomial distribution with 1 trial

=binom.inv(1, p, rand()) will generate 1 or 0 with chance of 1 being p.

Upvotes: 4

Robert Dodier
Robert Dodier

Reputation: 17585

If Excel doesn't have a random number generator for the binomial distribution (I didn't look), it's easy to make a simple one. Remember that a sample from a binomial distribution with parameters n and p is just the sum of n variables which are Bernoulli variables (i.e. simple coin tosses) with probability p. So you just generate n coin tosses, i.e. 1 with probability p and 0 with probability 1 - p, and add them up to get one sample from binomial(n, p).

There are more efficient ways to do it, but if you just need to get something working, this method has the advantage of simplicity.

Upvotes: 1

Related Questions