1. Home
  2. GRMNOMIAL procedure

GRMNOMIAL procedure

Generates multinomial pseudo-random numbers (D.B. Baird).

Options

NVALUES = scalar Number of values to generate
SEED = scalar Seed to generate the random numbers; default 0 continues an existing sequence or initializes the sequence automatically if no random numbers have been generated in this job

Parameters

PROBABILITIES = variates or tables Probabilities for the categories
NUMBERS = factors Saves the random numbers
COUNTS = tables Saves counts of the numbers generated in each category

Description

GRMNOMIAL generates pseudo-random numbers from a multinomial distribution. The probabilities for the categories are specified by the PROBABILITIES option, in either a variate or a table.

The numbers can be saved, in a factor, using the NUMBERS parameter. The NVALUES option specifies the number of values to be generated. If this is not set, the length of the NUMBERS factor is used or, if that has not been defined, a single value is generated.

The COUNTS parameter can save a table with counts of the numbers generated in each category. If COUNTS has not already been defined as a table with a suitable classifying factor, it is defined as follows. Firstly, if NUMBERS has been set, COUNTS is defined as a table with NUMBERS as the classifying factor. Otherwise, if PROBABILITIES has supplied a table rather than a variate, COUNTS is defined as a table classified by the same classifying factor as PROBABILITIES. Finally, the fall-back is to define COUNTS as a table with an unnamed classifying factor.

The SEED option can be set to initialize the random-number generator. The default of zero continues an existing sequence, or initializes the sequence automatically if no random numbers have been generated in this job.

Options: NVALUES, SEED.
Parameters: PROBABILITIES, NUMBERS, COUNTS.

Method

The pseudo-random numbers are generated using the GRUNIFORM function.

Action with RESTRICT

Any restrictions are ignored.

Directive: CALCULATE.
Procedures: GRANDOM, GRCSR, GREJECTIONSAMPLE, GRLABEL, GRMULTINORMAL, GRTHIN, GRTORSHIFT, SAMPLE, SVSAMPLE.
Functions: GRBETA, GRBINOMIAL, GRCHISQUARE, GRF, GRGAMMA, GRHYPERGEOMETRIC, GRLOGNORMAL, GRNORMAL, GRPOISSON, GRSAMPLE, GRSELECT, GRT, GRUNIFORM.
Commands for: Calculations and manipulation.

Example

CAPTION   'GRMNOMIAL example',\
          !t('Generate 200 values from a multinomial distribution',\
          'with probabilities 0.4, 0.3, 0.2 and 0.1.'); STYLE=meta,plain
VARIATE   [VALUES=0.4,0.3,0.2,0.1] Probabilities
FACTOR    [LABELS=!t(%40,%30,%20,%10)] Numbers
GRMNOMIAL [NVALUES=200; SEED=259452] Probabilities; NUMBERS=Numbers;\
          COUNTS=Counts
PRINT     Counts
Updated on September 11, 2019

Was this article helpful?