Random numbers from arbitrary distributions

Random numbers can be generated in Statistica for all continuous and discrete distributions, using the standard inversion method (Muller, 1959; see also Evans, Hastings, Peacock, B., 1993). First generate a uniform random number, and then use the inverse distribution function for the distribution of interest to generate the random variate values.

In practice, care must be taken not to use uniform random numbers that are (almost) 0 or (almost) 1, since the inverse distribution functions at the extreme margins may return in some cases the missing data code. For example, suppose you want to generate random variate values for the Weibull distribution with scale parameter .5, shape parameter .6, and location (threshold) parameter 10. You could use the following line in the Variable dialog box, in the Long label or formula field, to generate those values:


You could, of course, also use this formula in the appropriate context in a Statistica Visual Basic program, or any other place where Statistica accepts user-defined functions or equations. Note that the rnd(1) function will generate uniform random numbers in the range from 0 to 1; by multiplying those values by .99999 and adding .000001 you guarantee that the inverse Weibull distribution function vWeibull is not called with a very small (almost 0) or very large (almost 1) probability value (where it might return a missing value; the constants used in this example guarantee .000001<=p<=.999991); thus the variable computed in this manner is guaranteed to contain only valid random values from the specified Weibull distribution (except for the extreme tails).

Note that Statistica's probability routines are extremely robust, so you can use constants (to define a range 0<x<1) to include a wider range of probability values at the extreme ends of the 0-1 range if you want. However, the inverse probability functions for values that are equal to 0 are not defined, and will return missing data.

Monte Carlo Markov Chain analysis; Gibbs sampler. Monte Carlo and related techniques rely on the fast, efficient, and "precise" generation of random numbers from a variety of distributions. Numerous different types of specialized libraries are available for this purpose, and a good deal of ongoing research in this area is further refining these techniques and their applications. In general, custom random number (or other types of) routines can be incorporated into Statistica via Statistica Visual Basic with relative ease.

See also, DIEHARD Suite of Tests and Random Number Generation.