GRANDOM procedure
Generates pseudo-random numbers from probability distributions (D.M. Roberts & P.W. Lane).
Options
Parameter
Description
GRANDOM generates pseudo-random numbers from the beta, chi-square, exponential, F, gamma, log-Normal, Normal, Student's t, uniform, Weibull, binomial, hypergeometric and poisson distributions.
The NUMBERS parameter of GRANDOM must be set to a scalar or variate to store the generated numbers. The NVALUES option can be set to specify how many values are required; if this is unset, a single value is generated. The SEED option can be set to initialize the random-number generator, hence giving identical results if the procedure is called again with the same options. If SEED is unset, generation will continue from the previous sequence in the program, or, if this is the first generation, the generator will be initialized by CALCULATE.
Most distributions can be specified by their mean and variance. In GRANDOM these are defined by the MEAN and VARIANCE options. For some distributions there are other defining parameters, which are often more convenient. These can be set by other options relevant to the distribution concerned.
Normal distributions can be defined only by mean and variance; by default these are zero and one respectively. For the exponential and Poisson distributions, either one of these is sufficient to define the distribution and if neither is given the mean is set to one. For the Poisson if both are specified they must be equal, while for the exponential the variance is the square of the mean. The chi-square distribution can be defined by any one of the DF, MEAN or VARIANCE options (the mean is equal to the degrees of freedom, and the variance to twice the degrees of freedom). Similarly, the Student's t distribution can be defined by either the DF or the VARIANCE option; if MEAN is set, it must be zero. The F distribution can be generated by setting either the MEAN and VARIANCE options or the DFDENOMINATOR and DFNUMERATOR options.
The binomial distribution can be specified either by the MEAN and VARIANCE options (with MEAN greater than VARIANCE), or by the NBINOMIAL and PROBABILITY options. However, the hypergeometric distribution cannot be specified by MEAN and VARIANCE: instead the three options PROBABILITY, NHYPERGEOMETRIC and SSHYPERGEOMETRIC must be used.
The uniform distribution in the range (0,1) can be generated by setting the single option DIST=uniform. However, you can set the MEAN and VARIANCE options, or the LOWER and UPPER options, to get a uniform distribution in any other range. Similarly, the beta distribution is generated by default in the range (0,1), by setting the MEAN and VARIANCE options, or the ABETA and BBETA options: the mean is A/(A+B) and the variance is AB/((A+B+1)×(A+B)2). By setting the LOWER and UPPER options, the four-parameter beta distribution is generated, within the specified range.
The two-parameter gamma distribution can be generated by setting either the MEAN and VARIANCE options, or the AGAMMA and BGAMMA options. (The mean is AB and the variance is AB2: A is sometimes denoted by α or θ, and B by β or κ.) The three-parameter gamma can be generated by setting the LOCATION option, which simply has the effect of shifting a two-parameter gamma distribution. Similarly, the two- and three-parameter log-Normal distributions can be generated, though using the SCALE and SHAPE options rather than AGAMMA and BGAMMA. (If LOCATION is zero, the mean is sc × exp(sh2/2) and the variance is sc2 × exp(sh2) × (exp(sh2)-1; the square of the shape parameter is the variance of the associated Normal distribution, and the log(SCALE) is the mean.) The three-parameter Weibull is defined also by the LOCATION, SCALE and SHAPE options: it cannot be specified in terms of MEAN and VARIANCE. (The mean of the distribution is LOCATION+SCALE×G(1+1/SHAPE) and the variance is SCALE2×G(1+2/SHAPE)-(G(1+1/SHAPE))2), where G() is the gamma function.)
Options: DISTRIBUTION, NVALUES, SEED, MEAN, VARIANCE, LOWER, UPPER, LOCATION, SCALE, SHAPE, ABETA, BBETA, AGAMMA, BGAMMA, DF, DFNUMERATOR, DFDENOMINATOR, NBINOMIAL, PROBABILITY, NHYPERGEOMETRIC, SSHYPERGEOMETRIC.
Parameter: NUMBERS.
Method
GRANDOM uses the "table look-up" method for the majority of the distributions, using the ED** functions in the CALCULATE directive. It uses the transformation method for the Weibull distribution, and the rejection method for the binomial, hypergeometric and Poisson distributions.
Action with
RESTRICT
A variate that has been restricted will receive output from GRANDOM only in those units that are not excluded by the restriction. Values in the excluded units remain unchanged. Note that the NVALUES option must equal the full size of the variate.