next up previous index
Next: V112 Multinomial Random Up: CERNLIB Previous: V110 Poisson Random

V111 Binomial Random Numbers

Routine ID: V111
Author(s): D. DrijardLibrary: MATHLIB
Submitter: Submitted: 15.09.1978
Language: FortranRevised:

OBSOLETE

Please note that this routine has been obsoleted in CNL 218. Users are advised not to use it any longer and to replace it in older programs. No maintenance for it will take place and it will eventually disappear.
Suggested replacement: RNBNML (V137)

BINOMI generates a random integer N according to the binomial law:

Prob(N=n) = M nPn(1-P)M-n

where the 'sample size' M (a positive integer) and the probability P (0 ≤P ≤1 ) are specified by the user.

Structure:

SUBROUTINE subprogram
User Entry Names: BINOMI
External References: RNDM (V104)

Usage:

    CALL BINOMI(M,P,N,IERR)
M
( INTEGER) Sample size M.
P
( REAL) Probability.
N
( INTEGER) The generated random number, binomially distributed in the interval 0 ≤N ≤M with mean P*M.
IERR
( INTEGER) Error flag.
= 0: Normal case,
= 1: P ≤0 or P ≥1 .

Notes:

BINOMI should not be used when M is 'large' (say >100 ). The normal approximation is then recommended instead (with mean P*M+0.5 and standard deviation M*P*(1-P) ).

Los Alamos report LA-5061-MS.

V112


Janne Saarela
Mon Apr 3 15:06:23 METDST 1995