Main Content

nbininv

Negative binomial inverse cumulative distribution function

Syntax

X = nbininv(Y,R,P)

Description

X = nbininv(Y,R,P)returns the inverse of the negative binomial cdf with corresponding number of successes,Rand probability of success in a single trial,P. Since the binomial distribution is discrete,nbininvreturns the least integerXsuch that the negative binomial cdf evaluated atXequals or exceedsY.Y,R, andPcan be vectors, matrices, or multidimensional arrays that all have the same size, which is also the size ofX. A scalar input forY,R, orPis expanded to a constant array with the same dimensions as the other inputs.

The simplest motivation for the negative binomial is the case of successive random trials, each having a constant probabilityPof success. The number ofextratrials you must perform in order to observe a given numberRof successes has a negative binomial distribution. However, consistent with a more general interpretation of the negative binomial,nbininvallowsRto be any positive value, including nonintegers.

Examples

How many times would you need to flip a fair coin to have a 99% probability of having observed 10 heads?

flips = nbininv(0.99,10,0.5) + 10 flips = 33

Note that you have to flip at least 10 times to get 10 heads. That is why the second term on the right side of the equals sign is a 10.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced before R2006a