# Thread: Simulation of beta-binomial distribution

1. ## Simulation of beta-binomial distribution

Hi all!

I'm trying to solve the following problem.

The number of successes in a sequence of N yes/no experiments (i.e., N Bernoulli trials), each of which yields success with probability p, is given by the well-known binomial distribution. This is true if the success probability p is constant and the same for all the N trials.

However, when the probability of success, p, is different for each trial, p_1, p_2, ..., p_N, then the number of successes does not follow a binomial distribution, but a Poisson's binomial distribution instead:

Poisson binomial distribution - Wikipedia, the free encyclopedia

I understand that the Poisson's binomial distribution is valid for any set of probabilities p_1, p_2, ..., p_N.

In my problem, I know that the probabilities p_1, p_2, ..., p_N follow a beta distribution. I found out that, in such a case, the resulting PMF of the number of successes in N trials is given by the beta-binomial distribution:

Beta-binomial distribution - Wikipedia, the free encyclopedia

However, I have been playing a bit with some simulation and it seems that this distribution does not fit the resulting PMF. I'm attaching a Matlab file that makes some simulation and generates the PMFs.

What am I doing wrong? Is it possible to exploit the knowledge that the p_1, p_2, ..., p_N follow a beta distribution to simplify the general Poison's binomial case? What is the PMF that I need?