NBRAN SUBROUTINE NBRAN(N,P,NPAR,ISTART,X) PURPOSE--This subroutine generates a random sample of size N from the negative binomial distribution with single precision 'bernoulli probability' parameter = P, and integer 'number of successes in bernoulli trials' parameter = NPAR. The negative binomial distribution used herein has MEAN = NPAR*(1-P)/P and STANDARD DEVIATION = SQRT(NPAR*(1-P)/(P*P))). This distribution is defined for all non-negative integer X--X = 0, 1, 2, ... . This distribution has the probability function F(X) = C(NPAR+X-1,NPAR) * P**NPAR * (1-P)**X. Where C(NPAR+X-1,NPAR) is the combinatorial function equaling the number of combinations of NPAR+X-1 items taken NPAR at a time. The negative binomial distribution is the distribution of the number of failures before obtaining npar successes in an indefinite sequence of bernoulli (0,1) trials where the probability of success in a single trial = P. INPUT ARGUMENTS--N = The desired integer number of random numbers to be generated. --P = The single precision value of the 'bernoulli probability' parameter for the negative binomial NORPLT distbibution. P should be between 0.0 and 1.0 (exclusively). --NPAR = The integer value of the 'number of successes in bernoulli trials' parameter. NPAR should be a positive integer. --ISTART = An integer flag code which (if set to 0) will start the generator over and hence produce the same random sample over and over again upon successive calls to this subroutine within a run; or (if set to some integer value not equal to 0, like, say, 1) will allow the generator to continue from where it stopped and hence produce different random samples upon successive calls to this subroutine within a run. OUTPUT ARGUMENTS--X = A single precision vector (of dimension least N) into which the g generated random sampleill be placed. OUTPUT--A random sample of size N from the negative binomial distribution with 'bernoulli probability' parameter = P and 'number of successes in bernoulli trials' parameter = NPAR. PRINTING--None unless an input argument error condition exists. RESTRICTIONS--There is no restriction on the maximum value of N for this subroutine. --P should be between 0.0 and 1.0 (exclusively). --NPAR should be a positive integer. OTHER DATAPAC SUBROUTINES NEEDED--UNIRAN, BINRAN, GEORAN. FORTRAN LIBRARY SUBROUTINES NEEDED--None. MODE OF INTERNAL OPERATIONS--Single precision. LANGUAGE--ANSI FORTRAN. COMMENT--Note that even though the output from this discrete random number generator must necessarily be a sequence of ***integer*** values, the output vector X is single precision in mode. X has been specified as single precision so as to conform with the DATAPAC convention that all output vectors from all DATAPAC subroutines are single precision. This convention is based on the belief that 1) A mixture of modes (floating point versus integer) is inconsistent and an unnecessary complication in a data analysis; and 2) Floating point machine arithmetic (as opposed to integer arithmetic) is the more natural mode for doing data analysis. REFERENCES--Hasting and Peacock, Statistical Distributions--A Handbook for Students and Practitioners, 1975, Page 95. --Johnson and Kotz, Discrete Distributions, 1969, Pages 122-142. --Feller, An Introduction to Probability Theory and its Applications, Volume 1, Edition 2, 1957, Pages 155-157, 210. --National Bureau of Standards Applied Mathematics Series 55, 1964, Page 929. --Kendall and Stuart, The Advanced Theory of Statistics, Volume 1, Edition 2, 1963, Pages 130-131. WRITTEN BY--James J. Filliben Statistical Engineering Laboratory (205.03) National Bureau of Standards Gaithersburg, MD 20899 Phone-- 301-921-2315 ORIGINAL VERSION--November 1975.