If you repeatedly perform an experiment with probability of success p, then, given an integer n, the probability of k failures that occur before you have n successes is given by the negative binomial distribution, which can be computed by
| ⎛ ⎝ |
| ⎞ ⎠ | pn(1−p)k. (2) |
The negbinomial command finds the density function for the negative binomial distribution.
Example.
Input:
Output:
| 0.15625 |
Note that
| ⎛ ⎝ |
| ⎞ ⎠ | = |
| = |
|
The second formula makes sense even if n is negative, and you can write
| negbinomial(n,k,p) = | ⎛ ⎝ |
| ⎞ ⎠ | pn (p−1)k, |
from which the name negative binomial distribution comes from. This also makes it simple to determine the mean (n(1−p)/p) and variance (n(1−p)/p2). The negative binomial is also called the Pascal distribution (after Blaise Pascal) or the Pólya distribution (after George Pólya).
The negbinomial_cdf command finds the cumulative distribution function for the negative binomial distribution.
| Prob(X ≤ x) = negbinomial(n,0,p) + … + negbinomial(n,floor(x),p). |
| Prob(x ≤ X ≤ y) = negbinomial(n,ceil(x),p) + ⋯ + negbinomial(n,floor(y),p) |
Examples.
| 0.34375 |
| 0.40234375 |
The negbinomial_icdf command gives the inverse distribution function for the negative binomial distribution.
Example.
Input:
Output:
| 8 |