Negative binomial random numbers
RND = nbinrnd(R,P)
RND = nbinrnd(R,P,m,n,...)
RND = nbinrnd(R,P,[m,n,...])
RND = nbinrnd(R,P) is a matrix
of random numbers chosen from a negative binomial distribution with
corresponding number of successes,
R and probability
of success in a single trial,
be vectors, matrices, or multidimensional arrays that have the same
size, which is also the size of
RND. A scalar input
P is expanded to a
constant array with the same dimensions as the other input.
RND = nbinrnd(R,P,m,n,...) or
= nbinrnd(R,P,[m,n,...]) generates an
P parameters can
each be scalars or arrays of the same size as
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.
Suppose you want to simulate a process that has a defect probability of 0.01. How many units might Quality Assurance inspect before finding three defective items?
r = nbinrnd(3,0.01,1,6)+3 r = 496 142 420 396 851 178
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
The generated code can return a different sequence of numbers than MATLAB® if either of the following is true:
The output is nonscalar.
An input parameter is invalid for the distribution.
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).