Main Content

nbinpdf

Negative binomial probability density function

Syntax

Y = nbinpdf(X,R,P)

Description

Y = nbinpdf(X,R,P)returns the negative binomial pdf at each of the values inXusing the corresponding number of successes,Rand probability of success in a single trial,P.X,R, andPcan be vectors, matrices, or multidimensional arrays that all have the same size, which is also the size ofY. A scalar input forX,R, orPis expanded to a constant array with the same dimensions as the other inputs. Note that the density function is zero unless the values inXare integers.

The negative binomial pdf is

y = f ( x | r , p ) = ( r + x 1 x ) p r q x I ( 0 , 1 , ... ) ( x )

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,nbinpdfallowsRto be any positive value, including nonintegers. WhenRis noninteger, the binomial coefficient in the definition of the pdf is replaced by the equivalent expression

Γ ( r + x ) Γ ( r ) Γ ( x + 1 )

Examples

collapse all

Compute the pdf of a negative binomial distribution with parametersR = 3andp = 0.5.

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

Plot the pdf.

figure; plot(x,y,'+') xlim([-0.5,10.5])

Figure contains an axes object. The axes object contains an object of type line.

Extended Capabilities

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

版本历史

Introduced before R2006a