Discrete distribution
Binomial distribution
The number of successes in independent trials that each succeed with the same probability : heads in flips, defective parts in a batch of , correct guesses on a multiple-choice test. It is the sum of independent Bernoulli() variables.
Binomial probability calculator
P(X ≤ 3) = 0.649611
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
CDF
mean 3 · variance 2.1 · sd 1.449 · mode 3
Formulas
| Parameters |
|
|---|---|
| Support | |
| PMF | |
| CDF | |
| Mean | |
| Variance | |
| Mode | |
| MGF |
is the regularized incomplete beta function, which is how libraries evaluate the CDF.
Worked example
A quiz has 10 multiple-choice questions with 4 options each. A student guesses every answer. What is the probability of getting at least 5 right?
The number right is . About one guesser in thirteen passes. answer checked by code
How it relates to others
- Sum← Bernoulli: The sum of independent Bernoulli() variables is Binomial(). checked by code
- Special case→ Bernoulli: Binomial() is Bernoulli(). checked by code
- Limit→ Poisson: If and with fixed, Binomial() tends to Poisson(): the law of rare events. checked by code
- Limit→ Normal: For large , Binomial() is approximately Normal() (de Moivre–Laplace), best with a continuity correction. checked by code
- Limit← Hypergeometric: If the population with fixed, drawing without replacement is like drawing with it: Hypergeometric() tends to Binomial(). checked by code
- Special case← Multinomial: Multinomial with is the binomial, and any single count of a multinomial is Binomial(). checked by code
- Conjugate prior← Beta: A Beta() prior on and successes in binomial trials give a Beta() posterior. checked by code
- Limit← Beta-binomial: If with fixed, Beta-binomial() tends to Binomial(): the success rate stops varying. checked by code
All the relationships, as a diagram →
In Python
from scipy import stats
import numpy as np
X = stats.binom(n=10, p=0.3)
X.pmf(3) # P(X = 3) = 0.2668
X.cdf(3) # P(X ≤ 3) = 0.6496
X.mean(), X.var() # 3, 2.1
X.ppf(0.95) # 95th percentile
X.rvs(size=10, random_state=0)
rng = np.random.default_rng(0)
rng.binomial(n=10, p=0.3, size=10)Choosing between this and its neighbours? Which distribution for count data? · Which distribution for proportions and probabilities? · Which prior distribution should I use?