TheChymera - 8 months ago 116

Python Question

I would like to calculate the probability given by a binomial distribution for predetermined x(successes), n(trials), and p(probability) - the later of which is given by a probability mass function Beta(a,b).

I am aware of

`scipy.stats.binom.pmf(x,n,p)`

`loc`

`scipy.stats.binom.pmf`

Answer

Wiki says that the compound distribution function is given by

```
f(k|n,a,b) = comb(n,k) * B(k+a, n-k+b) / B(a,b)
```

where B is the beta function, a and b are the original Beta parameters and n is the Binomial one. k here is your x and p disappears because you integrate over the values of p to obtain this (convolution). That is, you won't find it in scipy but it is a one-liner provided you have the beta function from scipy.