Skip to main content
v2026.11,858 entries · CC-BY 4.0

Beta-Binomial Distribution: Formula, Overdispersion and a Worked Example

The beta-binomial distribution models counts whose success probability varies between units. Formula, worked example, overdispersion and code.

Written and maintained by CASRAI Editorial Board

Last updated

The beta-binomial distribution describes a count of successes out of n trials when the success probability is not fixed but varies from one unit to the next. It is a binomial distribution whose success probability p itself follows a beta distribution. Use it when binomial counts show more spread than a single fixed p allows (overdispersion). This guide gives the formula, a hand-worked example, and tested code.

What is the beta-binomial distribution?

A beta-binomial variable X counts successes in n trials. Two steps generate it: first draw a probability p from a beta distribution, then draw X from a binomial distribution with n trials and that p. Because p changes between units (classrooms, clinics, plates, litters), counts from different units are more variable than a binomial distribution predicts. The SciPy reference describes it as a binomial distribution whose success probability follows a beta distribution. JMP documents the same family with an overdispersion parameter, and states that when that parameter is zero the distribution reduces to the binomial.

The same distribution is the Bayesian posterior predictive for a binomial count under a beta prior, which is why you may meet it in Bayesian analysis as well as in overdispersed count modelling. See the comparison of Bayesian and frequentist statistics for that framing.

Beta binomial distribution formula and symbols

For k = 0, 1, …, n the probability mass function is:

P(X = k) = C(n, k) × B(k + α, n − k + β) / B(α, β)

  • n: number of trials, an integer ≥ 0.
  • k: number of successes, 0 to n.
  • α, β: shape parameters of the beta distribution for p, both > 0 (SciPy calls them a and b).
  • C(n, k): the binomial coefficient, n! / (k!(n − k)!).
  • B(x, y): the beta function, Γ(x)Γ(y) / Γ(x + y). For integers, B(x, y) = (x − 1)!(y − 1)! / (x + y − 1)!.

Mean and variance

Let p follow Beta(α, β), so E[p] = α/(α + β). By the law of total expectation, the mean is n × α/(α + β). The law of total variance gives Var(X) = E[n p(1 − p)] + Var(n p), which simplifies to:

Var(X) = n α β (α + β + n) / ((α + β)² (α + β + 1))

Define the mean probability p = α/(α + β) and the correlation parameter ρ = 1/(α + β + 1). Then the variance becomes n p (1 − p) [1 + (n − 1)ρ]. The first part is the binomial variance; the bracket is the inflation caused by p varying between units. When ρ = 0 the binomial is recovered. JMP’s delta parameter plays the role of ρ here, and its p is the mean probability, so α = p(1 − ρ)/ρ and β = (1 − p)(1 − ρ)/ρ.

Worked example with the arithmetic shown

Take n = 10 trials, α = 2, β = 3.

  1. Mean probability: p = 2/(2 + 3) = 0.4. Mean count = 10 × 0.4 = 4.
  2. Correlation parameter: ρ = 1/(2 + 3 + 1) = 1/6 ≈ 0.167.
  3. Variance: 10 × 2 × 3 × (2 + 3 + 10) / ((5)² × 6) = 900 / 150 = 6.0. Check with the other form: 10 × 0.4 × 0.6 × [1 + 9 × (1/6)] = 2.4 × 2.5 = 6.0.
  4. Binomial comparison: a binomial with n = 10 and p = 0.4 has the same mean 4 but variance 2.4. The beta-binomial variance is 2.5 times larger.
  5. Probability of exactly 4 successes: C(10, 4) = 210. B(2, 3) = 1!2!/4! = 1/12. B(6, 9) = 5!8!/14! = 1/18018. So P(X = 4) = 210 × (1/18018) / (1/12) = 2520/18018 = 0.1399. The binomial gives 0.2508.

The extra spread shows up in the tails. The chance of 0 or 10 successes is 0.0769 under the beta-binomial and 0.0062 under the binomial, about 12.5 times higher.

k Beta-binomial (n = 10, α = 2, β = 3) Binomial (n = 10, p = 0.4)
0 0.0659 0.0060
1 0.1099 0.0403
2 0.1349 0.1209
3 0.1439 0.2150
4 0.1399 0.2508
5 0.1259 0.2007
6 0.1049 0.1115
7 0.0799 0.0425
8 0.0539 0.0106
9 0.0300 0.0016
10 0.0110 0.0001

Beta-binomial vs binomial: reading overdispersion

The variance inflation factor is 1 + (n − 1)ρ. It depends on both ρ and the number of trials per unit, so a small ρ still matters when n is large.

ρ = 1/(α + β + 1) Inflation, n = 10 Inflation, n = 100 Reading
0.01 1.09 1.99 Near binomial at n = 10; clearly overdispersed at n = 100
0.05 1.45 5.95 Moderate overdispersion
0.10 1.90 10.90 Strong overdispersion
0.20 2.80 20.80 Very strong overdispersion

The inflation column is arithmetic from the formula above (for example 1 + 99 × 0.05 = 5.95); the reading column is a plain-language label, not a standard threshold. Large α + β means small ρ and a distribution close to the binomial. Small α + β means large ρ and heavy overdispersion. A related overdispersion remedy for unbounded counts is covered in the guide on negative binomial regression for overdispersion; the beta-binomial is the analogue for counts with a fixed upper limit n.

Bayesian reading

With a Beta(α, β) prior for p and y successes in n₁ trials, the posterior is Beta(α + y, β + n₁ − y). The predicted count in n₂ future trials is beta-binomial with parameters n₂, α + y, β + n₁ − y. Example: prior Beta(2, 3) and 6 successes in 10 trials give a Beta(8, 7) posterior. For 10 future trials the predictive mean is 10 × 8/15 = 5.33 and the variance is 10 × 8 × 7 × (15 + 10) / (15² × 16) = 14000/3600 = 3.89.

Assumptions and common mistakes

  • Each unit has a fixed number of trials n, and each trial is success or failure. For unbounded counts use the negative binomial distribution or the Poisson distribution instead.
  • Within a unit, trials share that unit’s p; across units, p follows a single beta distribution. If p depends on measured covariates, model them explicitly rather than absorbing them into ρ.
  • In the (α, β) form with both parameters positive, the beta-binomial can only represent overdispersion relative to the binomial (ρ > 0). It cannot describe counts that are less variable than binomial.
  • Mixing up parameterisations is the most common error. SciPy takes (n, a, b); JMP takes (k, p, n, delta). Convert with the formulas above before comparing outputs.
  • Testing for a difference in a proportion with a plain binomial interval when units are clustered understates uncertainty. For a single fixed-p sample, see the guide on the confidence interval for a proportion.

How to report it (APA example)

Illustrative wording, using the worked example’s values: “The number of correct responses out of 10 items per participant was modelled with a beta-binomial distribution (α = 2.0, β = 3.0), giving a mean of 4.0 and a variance of 6.0, compared with 2.4 under a binomial distribution with p = .40.” Report the parameterisation you used, the software and version, how the parameters were estimated, and the implied ρ. Use italics for statistical symbols such as n, p and k in APA style.

How to calculate it in Excel, R or Python

Excel has no built-in beta-binomial function, so build the mass function from logarithms of the gamma function. With n in B1, k in B2, α in B3, β in B4:

=COMBIN(B1,B2)*EXP(GAMMALN(B2+B3)+GAMMALN(B1-B2+B4)-GAMMALN(B1+B3+B4)-GAMMALN(B3)-GAMMALN(B4)+GAMMALN(B3+B4))

R (base R, using the log beta function; no package needed):

n <- 10; a <- 2; b <- 3; k <- 0:n
pmf <- exp(lchoose(n, k) + lbeta(k + a, n - k + b) - lbeta(a, b))
sum(k * pmf)               # mean, 4
sum(k^2 * pmf) - sum(k * pmf)^2   # variance, 6

Python (SciPy 1.4.0 or later):

from scipy.stats import betabinom
n, a, b = 10, 2, 3
betabinom.pmf(4, n, a, b)                  # 0.1399
betabinom.stats(n, a, b, moments='mv')     # (4.0, 6.0)
betabinom.rvs(n, a, b, size=1000)          # simulated counts

Each snippet reproduces the worked example: P(X = 4) = 0.1399, mean 4, variance 6.

FAQ

What is the difference between a binomial and a beta-binomial distribution?

A binomial assumes one fixed success probability for every trial. A beta-binomial lets that probability vary between units according to a beta distribution, which keeps the mean but increases the variance by the factor 1 + (n − 1)ρ.

What happens when the beta-binomial overdispersion is zero?

It reduces to the binomial distribution. In the (α, β) form this is the limit as α + β grows without bound, so ρ approaches 0.

Is the beta-binomial the same as the negative binomial?

No. The beta-binomial models a bounded count out of n trials. The negative binomial models an unbounded count, such as events or failures before a set number of successes.

Sources

  • SciPy documentation, scipy.stats.betabinom (v1.18.0), docs.scipy.org, checked 2026-10-29.
  • JMP Help 18.2, Discrete Probability Functions (Beta Binomial Probability), jmp.com, checked 2026-10-29.
  • Mean, variance and ρ follow from the beta mixing and the laws of total expectation and total variance; the worked example values agree with SciPy’s betabinom output.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about Beta-Binomial Distribution: Formula, Overdispersion and a Worked Example

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →

Ask CASRAI · Regulatory Radar

Research-admin question? Get an answer that links its sources.

An AI assistant specialized in research administration. Every answer links its sources to check before you act. 2 questions free, no account. $29/month after.

  • Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.
  • Every answer numbers its sources and links each one, so you can check the source yourself.