\section{RANDMULTI Generate Multinomial-distributed Random Variables}

\subsection{Usage}

This function generates samples from a multinomial distribution
given the probability of each outcome.  The general syntax for
its use is
\begin{verbatim}
   y = randmulti(N,pvec)
\end{verbatim}
where \verb|N| is the number of experiments to perform, and \verb|pvec|
is the vector of probabilities describing the distribution of
outcomes.
\subsection{Function Internals}

A multinomial distribution describes the number of times each
of \verb|m| possible outcomes occurs out of \verb|N| trials, where each
outcome has a probability \verb|p_i|.  More generally, suppose that
the probability of a Bernoulli random variable \verb|X_i| is \verb|p_i|,
and that 
\[
   \sum_{i=1}^{m} p_i = 1.
\]
Then the probability that \verb|X_i| occurs \verb|x_i| times is
\[
   P_N(x_1,x_2,\ldots,x_n) = \frac{N!}{x_1!\cdots x_n!} p_1^{x_1}\cdots p_n^{x_n}.
\]
\subsection{Example}

Suppose an experiment has three possible outcomes, say heads,
tails and edge, with probabilities \verb|0.4999|, \verb|0.4999| and
\verb|0.0002|, respectively.  Then if we perform ten thousand coin
flips we get
\begin{verbatim}
--> randmulti(10000,[0.4999,0.4999,0.0002])
ans = 
  <int32>  - size: [1 3]
 
Columns 1 to 3
 5026  4973     1  

\end{verbatim}
