next up previous index
Next: V138 Multinomial Random Up: CERNLIB Previous: V136 Poisson Random

V137 Binomial Random Numbers

Routine ID: V137
Author(s): D. Drijard, K.S. KölbigLibrary: MATHLIB
Submitter: Submitted: 15.10.1994
Language: FortranRevised:

Subroutine subprogram RNBNML generates a random integer N>0 according to the binomial distribution

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

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

Structure:

SUBROUTINE subprogram
User Entry Names: RNBNML
External References: RANLUX (V115)

Usage:

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

Notes:

RNBNML 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) ).

V138


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