Negative binomial probability density function
Y = nbinpdf(X,R,P)
Y = nbinpdf(X,R,P) returns
the negative binomial pdf at each of the values in
the corresponding number of successes,
R and probability
of success in a single trial,
P can be vectors, matrices, or multidimensional
arrays that all have the same size, which is also the size of
A scalar input for
expanded to a constant array with the same dimensions as the other
inputs. Note that the density function is zero unless the values in
The negative binomial pdf is
The simplest motivation for the negative binomial is the case
of successive random trials, each having a constant probability
success. The number of extra trials you must
perform in order to observe a given number
successes has a negative binomial distribution. However, consistent
with a more general interpretation of the negative binomial,
be any positive value, including nonintegers. When
noninteger, the binomial coefficient in the definition of the pdf
is replaced by the equivalent expression
Compute the Negative Binomial Distribution pdf
Compute the pdf of a negative binomial distribution with parameters
R = 3 and
p = 0.5.
x = (0:10); y = nbinpdf(x,3,0.5);
Plot the pdf.
figure; plot(x,y,'+') xlim([-0.5,10.5])
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).