Binomial Distribution
The binomial distribution counts successes in a fixed number of independent yes/no trials.
Setup
If you run n independent Bernoulli trials, each with success probability p, the number of successes X follows a Binomial(n, p) distribution. Its PMF is P(X = k) = C(n, k) pᵏ (1 − p)^{n−k}, where C(n, k) is the binomial coefficient counting the ways to place k successes among n trials.
Mean and variance
Because a binomial is a sum of n independent Bernoulli variables, E[X] = np and Var(X) = np(1 − p) follow immediately from linearity and additivity of variance. No summation over the PMF is required.
Shape and approximations
The distribution is symmetric when p = 0.5 and skewed otherwise. Two limits matter: for large n with p moderate it approaches a normal with the same mean and variance (a use of the central limit theorem), and for large n with small np it approaches a Poisson with rate λ = np.
from math import comb
def binom_pmf(k,n,p):
return comb(n,k)*p**k*(1-p)**(n-k)
print(round(binom_pmf(3,10,0.3),4)) # 0.2668
Where it appears
Any count of independent successes fits the binomial: defective units in a batch, detected events among trials, passing tests in a suite. It also underlies acceptance sampling, where a lot is accepted if defects in a sample stay below a threshold.
A caution
The independence and constant-p assumptions are strong. Correlated trials or a drifting success rate break the binomial, usually by making the real spread larger than np(1 − p) predicts — a pattern called overdispersion.