Negative Binomial random numbers
x = distfun_nbinrnd(R,P) x = distfun_nbinrnd(R,P,[m,n]) x = distfun_nbinrnd(R,P,m,n)
a matrix of doubles, the number of successes. R belongs to the set {0,1,2,3,4,.......}
a matrix of doubles, the probability of getting success in a Bernoulli trial. P in [0,1].
a 1-by-1 matrix of floating point integers, the number of rows of x
a 1-by-1 matrix of floating point integers, the number of columns of x
a matrix of doubles, the random numbers, in the set {0,1,2,3,...}.
Generates random variables from 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.
// Check with expanded R R = [10 100 1000 10000] P = 0.1 x = distfun_nbinrnd(R, P) // Check with expanded P R =100 P = [0.1 0.2 0.3 0.4] x = distfun_nbinrnd(R, P) // Check x = distfun_nbinrnd(R,P,[m,n]) x = distfun_nbinrnd(100,0.2,[4 5]) //Check mean and variance R = 10 P = 0.3 x = distfun_nbinrnd(R,P,[1 5000]); Mx = mean(x) Vx = variance(x) [M,V] = distfun_nbinstat(R,P) // Check actual distribution R=10; P=0.7; K=1000; h=scf(); x=distfun_nbinrnd(R,P,1,K); distfun_inthisto(x); h.children.children(1).children.background=-2; x=0:20; y=distfun_nbinpdf(x,R,P); plot(x,y,"ro-"); xtitle("Negative Binomial Random Numbers","X","Density") legend(["Empirical","Density"]); | ![]() | ![]() |
http://en.wikipedia.org/wiki/Negative_binomial_distribution