Statistics: nbincdf

### Function Reference: `nbincdf`

statistics: p = nbincdf (x, r, ps)
statistics: p = nbincdf (x, r, ps, `"upper"`)

Negative binomial cumulative distribution function (CDF).

For each element of x, compute the cumulative distribution function (CDF) of the negative binomial distribution with parameters r and ps, where r is the number of successes until the experiment is stopped and ps is the probability of success in each experiment, given the number of failures in x. The size of p is the common size of x, r, and ps. A scalar input functions as a constant matrix of the same size as the other inputs.

The algorithm uses the cumulative sums of the binomial masses.

`p = nbincdf (x, r, ps, "upper")` computes the upper tail probability of the negative binomial distribution with parameters r and ps, at the values in x.

When r is an integer, the negative binomial distribution is also known as the Pascal distribution and it models the number of failures in x before a specified number of successes is reached in a series of independent, identical trials. Its parameters are the probability of success in a single trial, ps, and the number of successes, r. A special case of the negative binomial distribution, when `r = 1`, is the geometric distribution, which models the number of failures before the first success.

r can also have non-integer positive values, in which form the negative binomial distribution, also known as the Polya distribution, has no interpretation in terms of repeated trials, but, like the Poisson distribution, it is useful in modeling count data. The negative binomial distribution is more general than the Poisson distribution because it has a variance that is greater than its mean, making it suitable for count data that do not meet the assumptions of the Poisson distribution. In the limit, as r increases to infinity, the negative binomial distribution approaches the Poisson distribution.

Further information about the negative binomial distribution can be found at https://en.wikipedia.org/wiki/Negative_binomial_distribution

See also: nbininv, nbinpdf, nbinrnd, nbinfit, nbinlike, nbinstat

Source Code: nbincdf

### Example: 1

     ## Plot various CDFs from the negative binomial distribution
     x = 0:50;
     p1 = nbincdf (x, 2, 0.15);
     p2 = nbincdf (x, 5, 0.2);
     p3 = nbincdf (x, 4, 0.4);
     p4 = nbincdf (x, 10, 0.3);
     plot (x, p1, "*r", x, p2, "*g", x, p3, "*k", x, p4, "*m")
     grid on
     xlim ([0, 40])
     legend ({"r = 2, ps = 0.15", "r = 5, ps = 0.2", "r = 4, p = 0.4", ...
              "r = 10, ps = 0.3"}, "location", "southeast")
     title ("Negative binomial CDF")
     xlabel ("values in x (number of failures)")
     ylabel ("probability")