<< Negative Binomial Negative Binomial distfun_nbininv >>

Distfun >> Distfun > Negative Binomial > distfun_nbincdf

distfun_nbincdf

Negative Binomial CDF

Calling Sequence

p = distfun_nbincdf(x,R,P)
p = distfun_nbincdf(x,R,P,lowertail)

Parameters

x:

a matrix of doubles, the extra trials for R successes, in the set {0,1,2,3,...}.

R :

a matrix of doubles, the number of successes. R belongs to the set {0,1,2,3,4,.......}

P :

a matrix of doubles, the probability of getting success in a Bernoulli trial. P in [0,1].

lowertail :

a 1-by-1 matrix of booleans, the tail (default lowertail=%t). If lowertail is true (the default), then considers P(X<=x) otherwise P(X>x).

p :

a matrix of doubles, the probability.

Description

Computes the cumulative distribution function of the Negative Binomial distribution function.

Any scalar input argument is expanded to a matrix of doubles of the same size as the other input arguments.

Examples

// Check with x scalar, R scalar, P scalar
computed = distfun_nbincdf(10,4,0.5)
expected = 0.9713135

// Check with expanded x
computed = distfun_nbincdf([5 10],4,0.5)
expected = [0.7460937    0.9713135]

// Check with expanded R
computed = distfun_nbincdf(5,[5 10],0.5)
expected = [0.6230469    0.1508789]

// Check with expanded P
computed = distfun_nbincdf(5,4,[0.5 0.7])
expected = [0.7460937    0.9747052]

// Check with two arguments expanded
computed = distfun_nbincdf([5 10],[5 7],0.5)
expected = [0.6230469    0.8338470]

// Check with all the arguments expanded
computed = distfun_nbincdf([5 10],[4 7],[0.5 0.6])
expected = [0.7460937    0.9651873]

//Plot the function
scf();
x = (0:20)';
p1=distfun_nbincdf(x,20,0.5);
p2=distfun_nbincdf(x,20,0.7);
p3=distfun_nbincdf(x,40,0.5);
legendspec=["P=0.5, N=20","P=0.7, N=20","P=0.5, N=40"];
distfun_plotintcdf(x,[p1,p2,p3],["b" "g" "r"],legendspec);
xtitle("Negative Binomial CDF")

//check upper tail
p = distfun_nbincdf(3,5,0.5)
lt_expected = 0.3632813

q = distfun_nbincdf(3,5,0.5,%f)
ut_expected = 0.6367187

Bibliography

http://en.wikipedia.org/wiki/Binomial_distribution

Authors


Report an issue
<< Negative Binomial Negative Binomial distfun_nbininv >>