Next: V113 Fast Uniform Up: CERNLIB Previous: V111 Binomial Random

## V112 Multinomial Random Numbers

Routine ID: V112
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: RNMNML (V138)

MUNOMI generates a vector of random integers $n$i (i=1,2,...,N) with probabilities $p$i

according to a multinomial law:

$Prob\left(n$1,n2,...,nN) = {(n1+n2+...+nN)!n1! n2! ... nN!} p1n1 p2n2 ... pNnN .

Structure:

SUBROUTINE subprogram
User Entry Names: MUNOMI
External References: RNDM (V104), UZERO (V300)

Usage:

```    CALL MUNOMI(NCH,NTOT,P,N,IERR)
```
NCH
( INTEGER) Number N of random integers $n$i

requested.

NTOT
( INTEGER) Equals $\sum$i=1Nni , specified by the user.
P
( REAL) One-dimensional array of length NCH at least. On entry, it contains in P(i) the probability of channel i. On return, it contains the cumulative channel probabilities so that $P\left(NCH\right)=1$ . If $P\left(NCH\right)=1$ on entry, it is assumed that P(i) contains the cumulative probabilities rather than the individual probabilites, which saves some time.
N
( INTEGER) One-dimensional array of length NCH at least. On return, N(i) contains the generated random integers.
IERR
Error flag.
$= 0:$ Normal case,
$= 1:$ At least one $P\left(i\right) < 0$ ,
$= 2:$ $\sum P\left(i\right) > 1$ .
$•$

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