Discrete distribution · also called Pólya urn distribution

Beta-binomial distribution

The number of successes in trials when the success probability is not fixed but varies from group to group as a Beta() variable: defects per batch when batches differ in quality, hits per player over a season, responders per clinic. It has the binomial's range but a wider spread (over-dispersion), and it is the posterior predictive distribution of a binomial count under a beta prior.

Beta-binomial probability calculator

P(X ≤ 4) = 0.594406

At the parameters set by the sliders. The shaded region on the plot is the probability; the dots on the CDF mark F at its ends. For a discrete distribution, < and ≤ differ.

PMF

00.050.10.150246810P(X = k)mean

CDF

00.250.50.7510246810F(x)

mean 4 · variance 6 · sd 2.449

Formulas

Parameters
  • , the number of trials
  • , , the shape of the beta distribution of the success probability
Support
PMF
CDF
Mean
Variance

With the variance is times , the over-dispersion factor; it tends to 1 (the binomial) as . is the beta function. With every count from 0 to is equally likely.

Worked example

The defect rate varies between production batches as Beta(2, 18), so it averages 10%. Ten parts are tested from one batch. What is the probability that none is defective?

A binomial with the average rate would give : when quality varies, clean batches and bad batches are both more common than a fixed rate suggests. answer checked by code

How it relates to others

All the relationships, as a diagram →

In Python

from scipy import stats
import numpy as np

X = stats.betabinom(n=10, a=2, b=3)
X.pmf(2)  # P(X = 2) = 0.1349
X.cdf(2)  # P(X ≤ 2) = 0.3107
X.mean(), X.var()  # 4, 6
X.ppf(0.95)  # 95th percentile
X.rvs(size=10, random_state=0)

rng = np.random.default_rng(0)
rng.binomial(n=10, p=rng.beta(a=2, b=3, size=10))

NumPy has no beta-binomial sampler: draw p from the beta, then a binomial with that p.

Choosing between this and its neighbours? Which distribution for count data? · Which distribution for proportions and probabilities? · Which prior distribution should I use?

← BinomialGeometric →