Main Content

nbinrnd

Negative binomial random numbers

Syntax

RND = nbinrnd(R,P)
RND = nbinrnd(R,P,m,n,...)
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,Rand probability of success in a single trial,P.RandPcan be vectors, matrices, or multidimensional arrays that have the same size, which is also the size ofRND. A scalar input forRorPis expanded to a constant array with the same dimensions as the other input.

RND = nbinrnd(R,P,m,n,...)orRND = nbinrnd(R,P,[m,n,...])generates anm-by-n-by-... array. TheR,Pparameters can each be scalars or arrays of the same size asR.

The simplest motivation for the negative binomial is the case of successive random trials, each having a constant probabilityPof success. The number ofextratrials you must perform in order to observe a given numberRof successes has a negative binomial distribution. However, consistent with a more general interpretation of the negative binomial,nbinrndallowsRto 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

Extended Capabilities

Introduced before R2006a