The RANTBL function
returns a variate that is generated from the probability mass function
defined by
p_{1} through
p_{n}. An inverse transform method applied to a RANUNI uniform variate
is used. RANTBL returns
$\begin{array}{cc}\hfill & \begin{array}{cc}1\hfill & with\phantom{\rule{0.212em}{0ex}}probability\phantom{\rule{0.212em}{0ex}}{p}_{1}\hfill \end{array}\hfill \\ \hfill & \begin{array}{cc}2\hfill & with\phantom{\rule{0.212em}{0ex}}probability\phantom{\rule{0.212em}{0ex}}{p}_{2}\hfill \end{array}\hfill \\ \hfill & \mathrm{.}\hfill \\ \hfill & \mathrm{.}\hfill \\ \hfill & \mathrm{.}\hfill \\ \hfill & \begin{array}{cc}n\hfill & with\phantom{\rule{0.212em}{0ex}}probability\phantom{\rule{0.212em}{0ex}}{p}_{n}\hfill \end{array}\hfill \\ \hfill & \begin{array}{cc}n+1\hfill & with\phantom{\rule{0.212em}{0ex}}probability\phantom{\rule{0.212em}{0ex}}\phantom{\rule{0.212em}{0ex}}1-\underset{i=1}{\overset{n}{\Sigma}}{p}_{i}\phantom{\rule{0.265em}{0ex}}\phantom{\rule{0.265em}{0ex}}if\underset{i=1}{\overset{n}{\Sigma}}{p}_{i}\le 1\hfill \end{array}\hfill \end{array}$
If, for some index
j<
n,
$\underset{i=1}{\overset{j}{\Sigma}}{p}_{i}\ge 1$ , RANTBL returns only the indices 1 through
j with the probability of occurrence of the
index
j equal to
$1-\underset{i=1}{\overset{j-1}{\Sigma}}{p}_{i}$ .
Let n=3 and P1, P2,
and P3 be three probabilities with P1+P2+P3=1, and M1, M2, and M3
be three variables. The variable X in these statements
array m{3} m1-m3;
x=m{rantbl(seed,of p1-p3)};
will be assigned one
of the values of M1, M2, or M3 with probabilities of occurrence P1,
P2, and P3, respectively.