Generate uniform and non-uniform random number distributions.

Namespace: Imsl.Stat
Assembly: ImslCS (in ImslCS.dll) Version: 6.5.0.0

Syntax

C#
[SerializableAttribute]
public class Random : Random
Visual Basic (Declaration)
<SerializableAttribute> _
Public Class Random _
	Inherits Random
Visual C++
[SerializableAttribute]
public ref class Random : public Random

Remarks

The non-uniform distributions are generated from a uniform distribution. By default, this class uses the uniform distribution generated by the base class Random. If the multiplier is set in this class then a multiplicative congruential method is used. The form of the generator is

x_i\equiv c
            x_{i-1}{\rm mod}(2^{31}-1)
Each x_i is then scaled into the unit interval (0,1). If the multiplier, c, is a primitive root modulo 2^{31}-1 (which is a prime), then the generator will have a maximal period of 
            2^{31}-2. There are several other considerations, however. See Knuth (1981) for a good general discussion. Possible values for c are 16807, 397204094, and 950706376. The selection is made by the property Multiplier. Evidence suggests that the performance of 950706376 is best among these three choices (Fishman and Moore 1982).

Alternatively, one can select a 32-bit or 64-bit Mersenne Twister generator by first instantiating MersenneTwister or MersenneTwister64. These generators have a period of 2^{19937}-1 and a 623-dimensional equidistribution property. See Matsumoto et al. 1998 for details.

The generation of uniform (0,1) numbers is done by the method NextFloat.

Nonuniform random numbers are generated using a variety of transformation procedures. All of the transformations used are exact (mathematically). The most straightforward transformation is the inverse CDF technique, but it is often less efficient than others involving acceptance/rejection and mixtures. See Kennedy and Gentle(1980) for discussion of these and other techniques.

Many of the nonuniform generators use different algorithms depending on the values of the parameters of the distributions. This is particularly true of the generators for discrete distributions. Schmeiser (1983) gives an overview of techniques for generating deviates from discrete distributions.

Extensive empirical tests of some of the uniform random number generators available in the Random class are reported by Fishman and Moore (1982 and 1986). Results of tests on the generator using the multiplier 16807 are reported by Learmonth and Lewis (1973). If the user wishes to perform additional tests, the routines in Chapter 17, Tests of Goodness of Fit, may be of use. Often in Monte Carlo applications, it is appropriate to construct an ad hoc test that is sensitive to departures that are important in the given application. For example, in using Monte Carlo methods to evaluate a one-dimensional integral, autocorrelations of order one may not be harmful, but they may be disastrous in evaluating a two-dimensional integral. Although generally the routines in this chapter for generating random deviates from nonuniform distributions use exact methods, and, hence, their quality depends almost solely on the quality of the underlying uniform generator, it is often advisable to employ an ad hoc test of goodness of fit for the transformations that are to be applied to the deviates from the nonuniform generator.

Three methods are associated with copulas. A copula is a multivariate cumulative probability distribution (CDF) whose arguments are random variables uniformly distributed on the interval [0,1] corresponding to the probabilities (variates) associated with arbitrarily distributed marginal deviates. The copula structure allows the multivariate CDF to be partitioned into the copula, which has associated with it information characterizing the dependence among the marginal variables, and the set of separate marginal deviates, each of which has its own distribution structure.

Two methods, NextGaussianCopula and NextStudentsTCopula, allow the user to specify a correlation structure (in the form of a Cholesky matrix) which can be used to imprint correlation information on a sequence of multivariate random vectors. Each call to one of these methods returns a random vector whose elements (variates) are each uniformly distributed on the interval [0,1] and correlated according to a user-specified Cholesky matrix. These variate vector sequences may then be inverted to marginal deviate sequences whose distributions and imprinted correlations are user-specified. Method NextGaussianCopula generates a random Gaussian copula sequence by inverting uniform [0,1] random numbers to N(0,1) deviates vectors, imprinting each vector with the correlation information by multiplying it with the Cholesky matrix, and then using the N(0,1) CDF to map the imprinted deviates back to uniform [0,1] variates. Method NextStudentsTCopula inverts a vector of uniform [0,1] random numbers to a Student's t deviate vector with mean 0 and user specified degrees of freedom df which is then imprinted with the Cholesky matrix and mapped back to uniform [0,1] variates.

The third copula method, CanonicalCorrelation, extracts a correlation matrix from a sequence of multivariate deviate vectors whose component marginals are arbitrarily distributed. This is accomplished by first extracting the empirical CDF from each of the marginal deviates and then using this CDF to map the deviates to uniform [0,1] variates which are then inverted to Normal (0,1) deviates. Each element C_{ij} of the correlation matrix can then be extracted by averaging the products z_{it}
            z_{jt} of deviates i and j over the t-indexed sequence. The utility of method CanonicalCorrelation is that because the correlation matrix is derived from N(0,1) deviates, the correlation is unbiased, i.e. undistorted by the arbitrary marginal distribution structures of the original deviate vector sequences. This is important in such financial applications as portfolio optimization, where correlation is used to estimate and minimize risk.

The use of these copula methods is illustrated with RandomEx2.cs, which first uses method NextGaussianCopula to create a correlation imprinted sequence of random deviate vectors and then uses method CanonicalCorrelation to extract the correlation matrix from the imprinted sequence of vectors.

Inheritance Hierarchy

See Also