next up previous index
Next: V150 Random Numbers Up: CERNLIB Previous: V137 Binomial Random

V138 Multinomial Random Numbers

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

Subroutine subprogram RNMNML generates a vector of random integers ni>0  (i=1,2,...,N) with probabilities pi

according to the multinomial distribution

Prob(n1,n2,...,nN) = {(n1+n2+...+nN)!n1! n2! ... nN!} p1n1 p2n2 ... pNnN .

Structure:

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

Usage:

    CALL RNMNML(N,NSUM,PCUM,NVEC,IERR)
N
( INTEGER) Number N of random integers ni

requested.

NSUM
( INTEGER) i=1Nni , specified by the user.
PCUM
( REAL) One-dimensional array of length ≥N . Must contains, on entry, the (normalized) cumulative channel probabilities j=1ipj

in PCUM(i) (i=1,...,N) . In particular, PCUM(N)=1 .

NVEC
( INTEGER) One-dimensional array of length ≥N . On exit, NVEC(i),(i = 1,...,N) contains the generated random integers.
IERR
Error flag.
= 0: Normal case,
= 1: PCUM(i) < PCUM(i-1)

for one i al least,
= 2: PCUM(N) ≠1 .

Notes:

For N=2, use RNBNML (V137).

V150


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