Random Numbers

 

Menu location: Data_Generating_Random Numbers.

 

This function enables you to create one or more series of random numbers from given distributions.

 

A robust generator of uniform (pseudo)random numbers is used as the basis for generating deviates from the probability distributions described below. You are given the opportunity to enter your own seed number to be used by the random number generator but you should use the default seed (based upon your computer's clock) in most cases. Please note that each seed generates its own series and that series is the same if you use the seed again. You have very little chance of using the same seed twice if you select the seed that StatsDirect suggests.

 

These functions are intended for simulation work; they employ widely cited and debated algorithms (Gentle, 2003).

 

Uniform (continuous uniform, rectangular)

The continuous uniform distribution has a constant density function of the interval (a, b) and thus a rectangular shape from a to b:

- where a and b lie between minus and plus infinity.

 

The interval most commonly used is 0 to 1

 

Normal (Gaussian)

The commonly used standard normal distribution (mean of 0 and standard deviation of 1) is one of a family of normal distributions defined by the density function:

- where mean μ lies between minus and plus infinity and standard deviation σ is greater than zero.

 

Algorithm: inversion of the cumulative distribution function (Wichura, 1988; Gentle 2003)

 

Lognormal

The density of a lognormal distribution is given by:

- where mean μ lies between minus and plus infinity and standard deviation σ is greater than zero.

 

The mean of the lognormal distribution, as opposed to the mean of the underlying normal distribution, is equal to exp(μ+σ2/2) and the variance is equal to exp(2μ+2σ2)-exp(2μ+σ).

 

Algorithm: transformed inversion of the cumulative distribution function (Wichura, 1988; Gentle 2003)

 

Exponential

The (negative) exponential distribution is a special case (shaping parameter of 1) of the gamma distribution. Its density is given by:

- where the parameter λ must be greater than zero.

 

Algorithm: transformation (Ahrens and Dieter, 1972).

 

Gamma

The density function of the gamma distribution is given by:

- where the parameters λ and r (shaping parameter) must be greater than zero.

 

G(*) is the gamma function:

 

Please note that gamma deviates with a shaping parameter of 0.5 are half the square of normal deviates and gamma deviates with a shaping parameter of 1 are exponential deviates.

 

Algorithm: acceptance-rejection methods GD and GS (Ahrens and Dieter, 1974, 1982b).

 

Binomial

The density function of the binomial distribution is given by:

- where p lies between 0 and 1 in n ranges.

 

Algorithm: acceptance-rejection method BTPEC (Kachitvichyanukul and Schmeiser, 1988).

 

Poisson

The density function of the Poisson distribution is given by:

- where parameter l is greater than zero.

 

Algorithm: acceptance-rejection (Ahrens and Dieter, 1982a).

 

Chi-square

The density function of the chi-square distribution is given by:

The deviates are calculated as gamma deviates with parameters n/2 and 2, where n is degrees of freedom.

 

Algorithm: Transformed gamma deviates (Ahrens and Dieter, 1974,1982b; Gentle 2003).

 

F (variance ratio)

The density function of the F distribution is given by:

The deviates are calculated as nx/dz where n is the numerator degrees of freedom, d is the denominator degrees of freedom, x is a gamma deviate with parameters n/2 and 2 (chi-square with n degrees of freedom), and z is a gamma deviate with parameters d/2 and 2 (chi-square with d degrees of freedom).

 

Algorithm: Transformed gamma deviates (Ahrens and Dieter, 1974, 1982b; Gentle 2003).

 

Student's t

The density function of Student's t distribution is given by:

The deviates are calculated as a standard normal deviate multiplied by the square root of the degrees of freedom (n) divided by a gamma deviate with parameters n/2 and 2 (a chi-square deviate with n degrees of freedom).

 

Algorithm: Transformed standard normal and gamma deviates (Ahrens and Dieter, 1974, 1982b; Gentle 2003).

 

Beta

The density function of the beta distribution is given by:

 

Algorithm: Acceptance-rejection methods BB and BC (Cheng 1978).

 

Logistic

The density function of the beta distribution is given by:

 

Algorithm: Transformed uniform deviates (Gentle 2003).

 

Cauchy

Algorithm: Transformed uniform deviates (Gentle 2003).

 

Weibull

Algorithm: Transformed uniform deviates (Gentle 2003).

 

Geometric

Algorithm: Transformed Poisson and exponential deviates (Devroye, 1986; Gentle 2003; Ahrens and Dieter, 1972, 1982a).

 

Negative binomial

Algorithm: Transformed Poisson and gamma deviates (Devroye, 1986; Gentle 2003; Ahrens and Dieter, 1974, 1982b, 1982a).