Products & Services Solutions Academia Support User Community Company

Learn more about Statistics Toolbox   

nbinrnd - Negative binomial random numbers

Syntax

RND = nbinrnd(R,P)
RND = nbinrnd(R,P,m)
RND = nbinrnd(R,P,m,n)

Description

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, P. R and P can be vectors, matrices, or multidimensional arrays that have the same size, which is also the size of RND. A scalar input for R or P is expanded to a constant array with the same dimensions as the other input.

RND = nbinrnd(R,P,m) generates random numbers with parameters R and P, where v is a row vector. If v is a 1-by-2 vector, R is a matrix with v(1) rows and v(2) columns. If v is 1-by-n, R is an n-dimensional array.

RND = nbinrnd(R,P,m,n) generates random numbers with parameters R and P, where scalars m and n are the row and column dimensions of RND.

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

Examples

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

See Also

random, nbinpdf, nbincdf, nbininv, nbinstat, nbinfit

Negative Binomial Distribution

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS