In probability theory and statistics, the binomial distribution with parameters and is the discrete probability distribution of the number of successes in a sequence of independent experiments, each asking a yes–no question, and each with its own Boolean-valued outcome: success (with probability) or failure (with probability). 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, i.e.,, the binomial distribution is a Bernoulli distribution. The binomial distribution is the basis for the popular binomial test of statistical significance.[1]
The binomial distribution is frequently used to model the number of successes in a sample of size drawn with replacement from a population of size . 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 much larger than, the binomial distribution remains a good approximation, and is widely used.
In general, if the random variable follows the binomial distribution with parameters and, we write . The probability of getting exactly successes in independent Bernoulli trials (with the same rate) is given by the probability mass function:
f(k,n,p)=\Pr(X=k)=\binom{n}{k}pk(1-p)n-k
\binom{n}{k}=
n! | |
k!(n-k)! |
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
f(k,n,p)=f(n-k,n,1-p).
Looking at the expression as a function of, there is a value that maximizes it. This value can be found by calculating
f(k+1,n,p) | = | |
f(k,n,p) |
(n-k)p | |
(k+1)(1-p) |
(n+1)p-1\leqM<(n+1)p.
is monotone increasing for and monotone decreasing for, with the exception of the case where (n + 1)p is an integer. In this case, there are two values for which is maximal: and . 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.
Equivalently,
M-p<np\leqM+1-p
Suppose a biased coin comes up heads with probability 0.3 when tossed. The probability of seeing exactly 4 heads in 6 tosses is
f(4,6,0.3)=\binom{6}{4}0.34(1-0.3)6-4=0.059535.
The cumulative distribution function can be expressed as:
F(k;n,p)=\Pr(X\lek)=
\lfloork\rfloor | |
\sum | |
i=0 |
{n\choosei}pi(1-p)n-i,
where
\lfloork\rfloor
It can also be represented in terms of the regularized incomplete beta function, as follows:[3]
\begin{align} F(k;n,p)&=\Pr(X\lek)\\ &=I1-p(n-k,k+1)\\ &=(n-k){n\choosek}
1-p | |
\int | |
0 |
tn-k-1(1-t)kdt. \end{align}
which is equivalent to the cumulative distribution function of the -distribution:[4]
F(k;n,p)=FF-distribution\left(x=
1-p | |
p |
k+1 | |
n-k |
;d1=2(n-k),d2=2(k+1)\right).
Some closed-form bounds for the cumulative distribution function are given below.
If, that is, X is a binomially distributed random variable, being the total number of experiments and p the probability of each experiment yielding a successful result, then the expected value of X is:[5]
\operatorname{E}[X]=np.
This follows from the linearity of the expected value along with the fact that is the sum of identical Bernoulli random variables, each with expected value . In other words, if
X1,\ldots,Xn
X=X1+ … +Xn
\operatorname{E}[X]=\operatorname{E}[X1+ … +Xn]=\operatorname{E}[X1]+ … +\operatorname{E}[Xn]=p+ … +p=np.
The variance is:
\operatorname{Var}(X)=npq=np(1-p).
This similarly follows from the fact that the variance of a sum of independent random variables is the sum of the variances.
The first 6 central moments, defined as
\muc=\operatorname{E}\left[(X-\operatorname{E}[X])c\right]
\begin{align} \mu1&=0,\ \mu2&=np(1-p),\\ \mu3&=np(1-p)(1-2p),\\ \mu4&=np(1-p)(1+(3n-6)p(1-p)),\\ \mu5&=np(1-p)(1-2p)(1+(10n-12)p(1-p)),\\ \mu6&=np(1-p)(1-30p(1-p)(1-4p(1-p))+5np(1-p)(5-26p(1-p))+15n2p2(1-p)2). \end{align}
The non-central moments satisfy
\begin{align} \operatorname{E}[X]&=np,\ \operatorname{E}[X2]&=np(1-p)+n2p2, \end{align}
\operatorname{E}[Xc]=
c | |
\sum | |
k=0 |
\left\{{c\atopk}\right\}n\underline{k
style\left\{{c\atopk}\right\}
n\underline{k
k
n
\operatorname{E}[Xc]\le \left(
c | |
log(c/(np)+1) |
\right)c\le(np)c\exp\left(
c2 | |
2np |
\right).
c=O(\sqrt{np})
\operatorname{E}[Xc]
\operatorname{E}[X]c
Usually the mode of a binomial B(n, p) distribution is equal to
\lfloor(n+1)p\rfloor
\lfloor ⋅ \rfloor
mode= \begin{cases} \lfloor(n+1)p\rfloor&if(n+1)pis0oranoninteger,\\ (n+1)p and (n+1)p-1&if(n+1)p\in\{1,...,n\},\\ n&if(n+1)p=n+1. \end{cases}
Proof: Let
f(k)=\binomnkpkqn-k.
For
p=0
f(0)
f(0)=1
p=1
f(n)=1
f(k)=0
k ≠ n
p=0
n
p=1
Let
0<p<1
f(k+1) | |
f(k) |
=
(n-k)p | |
(k+1)(1-p) |
From this follows
\begin{align} k>(n+1)p-1 ⇒ f(k+1)<f(k)\\ k=(n+1)p-1 ⇒ f(k+1)=f(k)\\ k<(n+1)p-1 ⇒ f(k+1)>f(k) \end{align}
So when
(n+1)p-1
(n+1)p-1
(n+1)p
(n+1)p-1\notin\Z
\lfloor(n+1)p-1\rfloor+1=\lfloor(n+1)p\rfloor
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:
np
np
\lfloornp\rfloor\leqm\leq\lceilnp\rceil
|m-np|\leqmin\{{ln2},max\{p,1-p\}\}
|m-np|\leqmin\{p,1-p\}
p=
1 | |
2 |
p=
1 | |
2 |
p=
1 | |
2 |
1 | |
2 |
l(n-1r)\leqm\leq
1 | |
2 |
l(n+1r)
p=
1 | |
2 |
m=
n | |
2 |
For k ≤ np, upper bounds can be derived for the lower tail of the cumulative distribution function
F(k;n,p)=\Pr(X\lek)
\Pr(X\gek)=F(n-k;n,1-p)
Hoeffding's inequality yields the simple bound
F(k;n,p)\leq\exp\left(-2n\left(p-
k | |
n |
\right)2\right),
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:[12]
F(k;n,p)\leq\exp\left(-nD\left(
k | |
n |
\parallelp\right)\right)
where D(a || p) is the relative entropy (or Kullback-Leibler divergence) between an a-coin and a p-coin (i.e. between the Bernoulli(a) and Bernoulli(p) distribution):
D(a\parallelp)=(a)log
a | +(1-a)log | |
p |
1-a | |
1-p |
.
Asymptotically, this bound is reasonably tight; see [12] for details.
One can also obtain lower bounds on the tail
F(k;n,p)
F(k;n,p)\geq
1 | |
\sqrt{8n\tfrac{k |
{n}(1-\tfrac{k}{n})}}\exp\left(-nD\left(
k | |
n |
\parallelp\right)\right),
F(k;n,p)\geq
1{\sqrt{2n}} | |||
|
\parallelp\right)\right).
For p = 1/2 and k ≥ 3n/8 for even n, it is possible to make the denominator constant:[14]
F(k;n,\tfrac{1}{2})\geq
1 | |
15 |
\exp\left(-16n\left(
1 | - | |
2 |
k | |
n |
\right)2\right).
When n is known, the parameter p can be estimated using the proportion of successes:
\widehat{p}=
x | |
n |
.
A closed form Bayes estimator for p also exists when using the Beta distribution as a conjugate prior distribution. When using a general
\operatorname{Beta}(\alpha,\beta)
\widehat{p}b=
x+\alpha | |
n+\alpha+\beta |
.
For the special case of using the standard uniform distribution as a non-informative prior,
\operatorname{Beta}(\alpha=1,\beta=1)=U(0,1)
\widehat{p}b=
x+1 | |
n+2 |
.
When relying on Jeffreys prior, the prior is
\operatorname{Beta}(\alpha= | 1 |
2 |
,\beta=
1 | |
2 |
)
\widehat{p}Jeffreys=
| ||||
n+1 |
.
When estimating p with very rare events and a small n (e.g.: if x=0), then using the standard estimator leads to
\widehat{p}=0,
\widehat{p}b
\widehat{p}b=
1 | |
n+2 |
.
\widehat{p}ruleof3=
3 | |
n |
.
See main article: Binomial proportion confidence interval.
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:
\widehat{p}=
n1 | |
n |
z
1-\tfrac{1}{2}\alpha
\alpha
\alpha
1-\tfrac{1}{2}\alpha
z
\widehat{p}\pmz\sqrt{
\widehat{p | |
( |
1-\widehat{p})}{n}}.
A continuity correction of 0.5/n may be added.
\tilde{p}\pmz\sqrt{
\tilde{p | |
( |
1-\tilde{p})}{n+z2}}
Here the estimate of p is modified to
\tilde{p}=
| ||||||
n+z2 |
This method works well for
n>10
n1 ≠ 0,n
n\leq10
n1=0,n
\sin2\left(\arcsin\left(\sqrt{\widehat{p}}\right)\pm
z | |
2\sqrt{n |
The notation in the formula below differs from the previous formulas in two respects:
z=z\alpha
z=z1
\alpha
z=z\alpha/2=z0.025=-1.96
z=z1=z0.975=1.96
\widehat{p | |
+ |
z2 | |
2n |
+z \sqrt{
\widehat{p | |
(1 |
-\widehat{p})}{n}+
z2 | |
4n2 |
} }{ 1+
z2 | |
n |
}
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.
If X ~ B(n, p) and Y ~ B(m, p) are independent binomial variables with the same probability p, then X + Y is again a binomial variable; its distribution is Z=X+Y ~ B(n+m, p):[22]
\begin{align} \operatornameP(Z=k)&=
k\left[\binom{n}i | |
\sum | |
i=0 |
pi(1-p)n-i\right]\left[\binom{m}{k-i}pk-i(1-p)m-k+i\right]\\ &=\binom{n+m}kpk(1-p)n+m-k\end{align}
A Binomial distributed random variable X ~ B(n, p) can be considered as the sum of n Bernoulli distributed random variables. So the sum of two Binomial distributed random variable X ~ B(n, p) and Y ~ B(m, p) is equivalent to the sum of n + m Bernoulli distributed random variables, which means Z=X+Y ~ B(n+m, p). This can also be proven directly using the addition rule.
However, if X and Y do not have the same probability p, then the variance of the sum will be smaller than the variance of a binomial variable distributed as
B(n+m,\bar{p}).
The binomial distribution is a special case of the Poisson binomial distribution, which is the distribution of a sum of n independent non-identical Bernoulli trials B(pi).[23]
This result was first derived by Katz and coauthors in 1978.[24]
Let and be independent. Let .
Then log(T) is approximately normally distributed with mean log(p1/p2) and variance .
If X ~ B(n, p) and Y | X ~ B(X, q) (the conditional distribution of Y, given X), then Y is a simple binomial random variable with distribution Y ~ B(n, pq).
For example, imagine throwing n balls to a basket UX and taking the balls that hit and throwing them to another basket UY. If p is the probability to hit UX then X ~ B(n, p) is the number of balls that hit UX. If q is the probability to hit UY then the number of balls that hit UY is Y ~ B(X, q) and therefore Y ~ B(n, pq).
Since
X\simB(n,p)
Y\simB(X,q)
\begin{align} \Pr[Y=m]&=
n | |
\sum | |
k=m |
\Pr[Y=m\midX=k]\Pr[X=k]\\[2pt] &=
n | |
\sum | |
k=m |
\binom{n}{k}\binom{k}{m}pkqm(1-p)n-k(1-q)k-m\end{align}
\tbinom{n}{k}\tbinom{k}{m}=\tbinom{n}{m}\tbinom{n-m}{k-m},
\Pr[Y=m]=
n | |
\sum | |
k=m |
\binom{n}{m}\binom{n-m}{k-m}pkqm(1-p)n-k(1-q)k-m
pk=pmpk-m
k
\begin{align} \Pr[Y=m]&=\binom{n}{m}pmqm\left(
n | |
\sum | |
k=m |
\binom{n-m}{k-m}pk-m(1-p)n-k(1-q)k-m\right)\\[2pt] &=\binom{n}{m}(pq)m\left(
n | |
\sum | |
k=m |
\binom{n-m}{k-m}\left(p(1-q)\right)k-m(1-p)n-k\right) \end{align}
i=k-m
\Pr[Y=m]=\binom{n}{m}(pq)m\left(
n-m | |
\sum | |
i=0 |
\binom{n-m}{i}(p-pq)i(1-p)n-m\right)
(p-pq+1-p)n-m
\begin{align} \Pr[Y=m]&=\binom{n}{m}(pq)m(p-pq+1-p)n-m\\[4pt] &=\binom{n}{m}(pq)m(1-pq)n-m\end{align}
Y\simB(n,pq)
The Bernoulli distribution is a special case of the binomial distribution, where n = 1. Symbolically, X ~ B(1, p) has the same meaning as X ~ Bernoulli(p). Conversely, any binomial distribution, B(n, p), is the distribution of the sum of n independent Bernoulli trials, Bernoulli(p), each with the same probability p.[25]
If n is large enough, then the skew of the distribution is not too great. In this case a reasonable approximation to B(n, p) is given by the normal distribution
l{N}(np,np(1-p)),
and this basic approximation can be improved in a simple way by using a suitable continuity correction.The basic approximation generally improves as n increases (at least 20) and is better when p is not near to 0 or 1.[26] Various rules of thumb may be used to decide whether n is large enough, and p is far enough from the extremes of zero or one:
|1-2p| | |
\sqrt{np(1-p) |
\mu\pm3\sigma=np\pm3\sqrt{np(1-p)}\in(0,n).
This 3-standard-deviation rule is equivalent to the following conditions, which also imply the first rule above.
n>9\left(
1-p | |
p |
\right) and n>9\left(
p | |
1-p |
\right).
np\pm3\sqrt{np(1-p)}\in(0,n)
np-3\sqrt{np(1-p)}>0 and np+3\sqrt{np(1-p)}<n.
np>3\sqrt{np(1-p)} and n(1-p)>3\sqrt{np(1-p)}.
0<p<1
np2
n(1-p)2
n>9\left(
1-p | |
p\right) |
and n>9\left(
p | |
1-p |
\right).
n>9
\sqrt{n | |
\sqrt{n | |
\left|\sqrt{ | 1-p | ||
|
np
n(1-p)
np
n(1-p)
0<p<1
np\geq9>9(1-p) and n(1-p)\geq9>9p.
p
1-p
n>9\left(
1-p | |
p\right) |
and n>9\left(
p | |
1-p |
\right).
The following is an example of applying a continuity correction. Suppose one wishes to calculate Pr(X ≤ 8) for a binomial random variable X. If Y has a distribution given by the normal approximation, then Pr(X ≤ 8) is approximated by Pr(Y ≤ 8.5). The addition of 0.5 is the continuity correction; the uncorrected normal approximation gives considerably less accurate results.
This approximation, known as de Moivre–Laplace theorem, is a huge time-saver when undertaking calculations by hand (exact calculations with large n are very onerous); historically, it was the first use of the normal distribution, introduced in Abraham de Moivre's book The Doctrine of Chances in 1738. Nowadays, it can be seen as a consequence of the central limit theorem since B(n, p) is a sum of n independent, identically distributed Bernoulli variables with parameter p. This fact is the basis of a hypothesis test, a "proportion z-test", for the value of p using x/n, the sample proportion and estimator of p, in a common test statistic.[29]
For example, suppose one randomly samples n people out of a large population and ask them whether they agree with a certain statement. The proportion of people who agree will of course depend on the sample. If groups of n people were sampled repeatedly and truly randomly, the proportions would follow an approximate normal distribution with mean equal to the true proportion p of agreement in the population and with standard deviation
\sigma=\sqrt{
p(1-p) | |
n |
The binomial distribution converges towards the Poisson distribution as the number of trials goes to infinity while the product np converges to a finite limit. Therefore, the Poisson distribution with parameter λ = np can be used as an approximation to B(n, p) of the binomial distribution if n is sufficiently large and p is sufficiently small. According to rules of thumb, this approximation is good if n ≥ 20 and p ≤ 0.05[30] such that np ≤ 1, or if n > 50 and p < 0.1 such that np < 5,[31] or if n ≥ 100 and np ≤ 10.[32] [33]
Concerning the accuracy of Poisson approximation, see Novak,[34] ch. 4, and references therein.
X-np | |
\sqrt{np(1-p) |
approaches the normal distribution with expected value 0 and variance 1. This result is sometimes loosely stated by saying that the distribution of X is asymptotically normal with expected value 0 and variance 1. This result is a specific case of the central limit theorem.
The binomial distribution and beta distribution are different views of the same model of repeated Bernoulli trials. The binomial distribution is the PMF of successes given independent events each with a probability of success. Mathematically, when and, the beta distribution and the binomial distribution are related by a factor of :
\operatorname{Beta}(p;\alpha;\beta)=(n+1)B(k;n;p)
Beta distributions also provide a family of prior probability distributions for binomial distributions in Bayesian inference:[35]
P(p;\alpha,\beta)=
p\alpha-1(1-p)\beta-1 | |
\operatorname{Beta |
(\alpha,\beta)}.
Methods for random number generation where the marginal distribution is a binomial distribution are well-established.[37] [38] 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 for all values from through . (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.
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.[39]