Documentation Center |
Negative binomial mean and variance
[M,V] = nbinstat(R,P)
[M,V] = nbinstat(R,P) returns the mean of and variance for the 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 all have the same size, which is also the size of M and V. A scalar input for R or P is expanded to a constant array with the same dimensions as the other input.
The mean of the negative binomial distribution with parameters r and p is rq / p, where q = 1 – p. The variance is rq / p2.
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, nbinstat allows R to be any positive value, including nonintegers.
p = 0.1:0.2:0.9; r = 1:5; [R,P] = meshgrid(r,p); [M,V] = nbinstat(R,P) M = 9.0000 18.0000 27.0000 36.0000 45.0000 2.3333 4.6667 7.0000 9.3333 11.6667 1.0000 2.0000 3.0000 4.0000 5.0000 0.4286 0.8571 1.2857 1.7143 2.1429 0.1111 0.2222 0.3333 0.4444 0.5556 V = 90.0000 180.0000 270.0000 360.0000 450.0000 7.7778 15.5556 23.3333 31.1111 38.8889 2.0000 4.0000 6.0000 8.0000 10.0000 0.6122 1.2245 1.8367 2.4490 3.0612 0.1235 0.2469 0.3704 0.4938 0.6173