Contenuto principale

nbincdf

Negative binomial cumulative distribution function

Description

y = nbincdf(x,r,p) returns the negative binomial cumulative distribution function (cdf), evaluated at the values in x, using the corresponding number of successes r and the probability of success in a single trial p.

example

y = nbincdf(x,r,p,"upper") returns the complement of the negative binomial cdf, evaluated at the values in x, using an algorithm that more accurately computes the extreme upper-tail probabilities as compared to subtracting the lower-tail value from 1.

example

Examples

collapse all

Compute the cumulative distribution function (cdf) values evaluated at the values in x for the negative binomial distribution assuming three successes and a 50% probability of success for each trial.

x = 0:0.01:10;
y = nbincdf(x,3,0.5);

Plot the cdf.

plot(x,y)
grid on
xlabel("x")
ylabel("y")

Figure contains an axes object. The axes object with xlabel x, ylabel y contains an object of type line.

As shown in the plot, the value of y at x = 2 is 0.5, which means there is a 50% chance that you will get three successes after at most two failures.

Determine the probability that the fifth success occurs after more than 50 failures if there is a 75% probability of success for each trial. To determine the probability, compute the negative binomial cdf for x = 50 failures and subtract the result from 1.

p1 = 1 - nbincdf(50,5,0.75)
p1 = 
0

The probability is so close to 1 that subtracting the result from 1 gives 0.

To approximate the extreme upper-tail probability with greater precision, compute the complement of the negative binomial cdf directly.

p2 = nbincdf(50,5,0.75,"upper")
p2 = 
2.1838e-26

The output indicates a small probability of the fifth success occurring after more than 50 failures.

Input Arguments

collapse all

Values at which to evaluate the negative binomial cdf, specified as a nonnegative scalar or an array of nonnegative scalars.

To evaluate the cdf at multiple values, specify x as an array. To evaluate the cdfs of multiple distributions, specify either r or p (or both) using arrays. If one or more of the input arguments x, r, and p are arrays, then the array sizes must be the same. In this case, nbincdf expands each scalar input into a constant array of the same size as the array inputs. Each element in y is the cdf value of the distribution specified by the corresponding elements in r and p, evaluated at the corresponding element in x.

Data Types: single | double

Number of successes, specified as a positive scalar or an array of positive scalars.

To evaluate the cdf at multiple values, specify x as an array. To evaluate the cdfs of multiple distributions, specify either r or p (or both) using arrays. If one or more of the input arguments x, r, and p are arrays, then the array sizes must be the same. In this case, nbincdf expands each scalar input into a constant array of the same size as the array inputs. Each element in y is the cdf value of the distribution specified by the corresponding elements in r and p, evaluated at the corresponding element in x.

Data Types: single | double

Probability of success, specified as a positive scalar in the range (0,1] or an array of positive scalars in the range (0,1].

To evaluate the cdf at multiple values, specify x as an array. To evaluate the cdfs of multiple distributions, specify either r or p (or both) using arrays. If one or more of the input arguments x, r, and p are arrays, then the array sizes must be the same. In this case, nbincdf expands each scalar input into a constant array of the same size as the array inputs. Each element in y is the cdf value of the distribution specified by the corresponding elements in r and p, evaluated at the corresponding element in x.

Data Types: single | double

Output Arguments

collapse all

Negative binomial cdf values, returned as a numeric scalar or array. y is the same size as x, r, and p after any necessary scalar expansion. Each element in y is the cdf value of the distribution specified by the corresponding elements in r and p, evaluated at the corresponding element in x.

More About

collapse all

Alternative Functionality

  • nbincdf is a function specific to the negative binomial distribution. Statistics and Machine Learning Toolbox™ also offers the generic function cdf, which supports various probability distributions. To use cdf, create a NegativeBinomialDistribution probability distribution object and pass the object as an input argument or specify the probability distribution name and its parameters. Note that the distribution-specific function nbincdf is faster than the generic function cdf.

  • Use the Probability Distribution Function Tool to create an interactive plot of the cumulative distribution function (cdf) or probability density function (pdf) for a probability distribution.

Extended Capabilities

expand all

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

Version History

Introduced before R2006a