Binomial distribution
Probability distribution

In probability theory and statistics, the binomial distribution with parameters n and p is the discrete probability distribution of the number of successes in a sequence of n independent experiments, each asking a yes-no question, and each with its own Boolean-valued outcome: success (with probability p) or failure (with probability q = 1 − p). A single success/failure experiment is also called a Bernoulli trial or Bernoulli experiment, and a sequence of outcomes is called a Bernoulli process. For a single trial, that is, when n = 1, the binomial distribution is a Bernoulli distribution. The binomial distribution is the basis for the binomial test of statistical significance.
The binomial distribution is frequently used to model the number of successes in a sample of size n drawn with replacement from a population of size N. If the sampling is carried out without replacement, the draws are not independent and so the resulting distribution is a hypergeometric distribution, not a binomial one. However, for N much larger than n, the binomial distribution remains a good approximation, and is widely used.
01Definitions
Probability mass function
If the random variable X follows the binomial distribution with parameters (a natural number) and p ∈ [0, 1], we write X ~ B(n, p). The probability of getting exactly k successes in n independent Bernoulli trials (with the same rate p) is given by the probability mass function:
for k = 0, 1, 2, ..., n, where
is the binomial coefficient. The formula can be understood as follows: pk qn−k is the probability of obtaining the sequence of n independent Bernoulli trials in which k trials are "successes" and the remaining n − k trials are "failures". Since the trials are independent with probabilities remaining constant between them, any sequence of n trials with k successes (and n − k failures) has the same probability of being achieved (regardless of positions of successes within the sequence). There are
such sequences, since the binomial coefficient
counts the number of ways to choose the positions of the k successes among the n trials. The binomial distribution is concerned with the probability of obtaining any of these sequences, meaning the probability of obtaining one of them (pk qn−k) must be added
times, hence
.
In creating reference tables for binomial distribution probability, usually, the table is filled in up to values. This is because for
, the probability can be calculated by its complement as
Looking at the expression f(k, n, p) as a function of k, there is a k value that maximizes it. This k value can be found by calculating
and comparing it to 1. There is always an integer M that satisfies
f(k, n, p) is monotone increasing for k < M and monotone decreasing for k > M, with the exception of the case where (n + 1)p is an integer. In this case, there are two values for which f is maximal: (n + 1)p and (n + 1)p − 1. M is the most probable outcome (that is, the most likely, although this can still be unlikely overall) of the Bernoulli trials and is called the mode.
Example
Suppose a biased coin comes up heads with probability 0.3 when tossed. The probability of seeing exactly 4 heads in 6 tosses is
Cumulative distribution function
The cumulative distribution function can be expressed as:
where
is the "floor" under k; that is, the greatest integer less than or equal to k.
It can also be represented in terms of the regularized incomplete beta function, as follows:
which is equivalent to the cumulative distribution functions of the beta distribution and of the F-distribution:
Some closed-form bounds for the cumulative distribution function are given below.

02Properties
Expected value and variance
If X ~ B(n, p), that is, X is a binomially distributed random variable, n being the total number of experiments and p the probability of each experiment yielding a successful result, then the expected value of X is:
This follows from the linearity of the expected value along with the fact that X is the sum of n identical Bernoulli random variables, each with expected value p. In other words, if are identical (and independent) Bernoulli random variables with parameter p, then X = X1 + ... + Xn and
The variance is:
This similarly follows from the fact that the variance of a sum of independent random variables is the sum of the variances.
Higher moments
The first 6 central moments, defined as , are given by
The non-central moments satisfy
and in general
where
are the Stirling numbers of the second kind, and
is the
-th falling power of
.
A simple bound
follows by bounding the Binomial moments via the higher Poisson moments:
This shows that if
, then
is at most a constant factor away from
.
The moment-generating function is .
Mode
Usually the mode of a binomial B(n, p) distribution is equal to , where
is the floor function. However, when (n + 1)p is an integer and p is neither 0 nor 1, then the distribution has two modes: (n + 1)p and (n + 1)p − 1. When p is equal to 0 or 1, the mode will be 0 and n correspondingly. These cases can be summarized as follows:
Proof: Let
For only
has a nonzero value with
. For
we find
and
for
. This proves that the mode is 0 for
and
for
.
Let . We find
From this follows
So when is an integer, then
and
is a mode. In the case that
, then only
is a mode.
Median
In general, there is no single formula to find the median for a binomial distribution, and it may even be non-unique. However, several special results have been established:
- If np is an integer, then the mean, median, and mode coincide and equal np.
- Any median m must lie within the interval
.
- A median m cannot lie too far away from the mean:
.
- The median is unique and equal to m = round(np) when |m − np| ≤ min{p, 1 − p} (except for the case when p = 1/2 and n is odd).
- When p is a rational number (with the exception of p = 1/2 and n odd), the median is unique.
- When
and n is odd, any number m in the interval
is a median of the binomial distribution. If
and n is even, then
is the unique median.
Tail bounds
For k ≤ np, upper bounds can be derived for the lower tail of the cumulative distribution function , the probability that there are at most k successes. Since
, these bounds can also be seen as bounds for the upper tail of the cumulative distribution function for k ≥ np.
Hoeffding's inequality yields the simple bound
which is however not very tight. In particular, for p = 1, we have that F(k; n, p) = 0 (for fixed k, n with k < n), but Hoeffding's bound evaluates to a positive constant.
A sharper bound can be obtained from the Chernoff bound:
where D(a ∥ p) is the relative entropy (or Kullback-Leibler divergence) between an a-coin and a p-coin (that is, between the Bernoulli(a) and Bernoulli(p) distribution):
Asymptotically, this bound is reasonably tight; see for details.
One can also obtain lower bounds on the tail F(k; n, p), known as anti-concentration bounds. By approximating the binomial coefficient with Stirling's formula it can be shown that
which implies the simpler but looser bound
For p = 1/2 and k ≥ 3n/8 for even n, it is possible to make the denominator constant:
03Statistical inference
Estimation of parameters
When n is known, the parameter p can be estimated using the proportion of successes:
This estimator is found using maximum likelihood estimator and also the method of moments. This estimator is unbiased and uniformly with minimum variance, proven using Lehmann-Scheffé theorem, since it is based on a minimal sufficient and complete statistic (that is, x). It is also consistent both in probability and in MSE. This statistic is asymptotically normal thanks to the central limit theorem, because it is the same as taking the mean over Bernoulli samples. It has a variance of
, a property which is used in various ways, such as in Wald's confidence intervals.
A closed form Bayes estimator for p also exists when using the Beta distribution as a conjugate prior distribution. When using a general as a prior, the posterior mean estimator is:
The Bayes estimator is asymptotically efficient and as the sample size approaches infinity (n → ∞), it approaches the MLE solution. The Bayes estimator is biased (how much depends on the priors), admissible and consistent in probability. Using the Bayesian estimator with the Beta distribution can be used with Thompson sampling.
For the special case of using the standard uniform distribution as a non-informative prior, , the posterior mean estimator becomes:
(A posterior mode should just lead to the standard estimator.) This method is called the rule of succession, which was introduced in the 18th century by Pierre-Simon Laplace.
When relying on Jeffreys prior, the prior is , which leads to the estimator:
When estimating p with very rare events and a small n (for example, if x = 0), then using the standard estimator leads to which sometimes is unrealistic and undesirable. In such cases there are various alternative estimators. One way is to use the Bayes estimator
, leading to:
Another method is to use the upper bound of the confidence interval obtained using the rule of three:
Confidence intervals for the parameter p
Even for quite large values of n, the actual distribution of the mean is significantly nonnormal. Because of this problem several methods to estimate confidence intervals have been proposed.
In the equations for confidence intervals below, the variables have the following meaning:
- n1 is the number of successes out of n, the total number of trials
is the proportion of successes
is the
quantile of a standard normal distribution (that is, probit) corresponding to the target error rate
. For example, for a 95% confidence level the error
, so
and
.
Wald method
A continuity correction of 0.5 / n may be added.
Agresti-Coull method
Here the estimate of p is modified to
This method works well for n > 10 and n1 ≠ 0, n. See here for . For n1 = 0, n use the Wilson (score) method below.
Arcsine method
Wilson (score) method
The notation in the formula below differs from the previous formulas in two respects:
- Firstly, zx has a slightly different interpretation in the formula below: it has its ordinary meaning of 'the xth quantile of the standard normal distribution', rather than being a shorthand for 'the (1 − x)th quantile'.
- Secondly, this formula does not use a plus-minus to define the two bounds. Instead, one may use
to get the lower bound, or use
to get the upper bound. For example: for a 95% confidence level the error
, so one gets the lower bound by using
, and one gets the upper bound by using
.
Comparison
The so-called "exact" (Clopper-Pearson) method is the most conservative. (Exact does not mean perfectly accurate; rather, it indicates that the estimates will not be less conservative than the true value.)
The Wald method, although commonly recommended in textbooks, is the most biased.
05Computational methods
Random number generation
Methods for random number generation where the marginal distribution is a binomial distribution are well-established. One way to generate random variates samples from a binomial distribution is to use an inversion algorithm. To do so, one must calculate the probability that Pr(X = k) for all values k from 0 through n. (These probabilities should sum to a value close to one, in order to encompass the entire sample space.) Then by using a pseudorandom number generator to generate samples uniformly between 0 and 1, one can transform the calculated samples into discrete numbers by using the probabilities calculated in the first step.
06History
This distribution was derived by Jacob Bernoulli. He considered the case where p = r/(r + s) where p is the probability of success and r and s are positive integers. Blaise Pascal had earlier considered the case where p = 1/2, tabulating the corresponding binomial coefficients in what is now recognized as Pascal's triangle.
Sources and credits
This article is adapted from the Wikipedia article “Binomial distribution”, written by its contributors and licensed under CC BY-SA 4.0. Fathomly has changed the layout, removed citation markers, navigation and maintenance notices, and adjusted punctuation. This adapted version is shared under the same license. For references, see the original article.
Images, from Wikimedia Commons:
- Binomial distribution pmf.svg by Tayste, Public domain
- Pascal's triangle; binomial distribution.svg by Watchduck You can name the author as "T. Piesk", "Tilman Piesk" or "Watchduck"., Public domain
- Binomial Distribution.svg by Cflm001 (talk), CC BY-SA 3.0
Fathomly is not affiliated with or endorsed by the Wikimedia Foundation. Spotted a problem? Tell us.
