Click or drag to resize
Random Class
Generate uniform and non-uniform random number distributions.
Inheritance Hierarchy

Namespace: Imsl.Stat
Assembly: ImslCS (in ImslCS.dll) Version: 6.5.2.0
Syntax
[SerializableAttribute]
public class Random : Random

The Random type exposes the following members.

Constructors
  NameDescription
Public methodRandom
Constructor for the Random number generator class.
Public methodRandom(Int32)
Constructor for the Random number generator class with supplied seed.
Public methodRandom(RandomBaseGenerator)
Constructor for the Random number generator class with an alternate basic number genrator.
Top
Methods
  NameDescription
Public methodCanonicalCorrelation

Method CanonicalCorrelation generates a canonical correlation matrix from an arbitrarily distributed multivariate deviate sequence with nvar deviate variables, nseq steps in the sequence, and a Gaussian Copula dependence structure.

Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodNext
Returns a nonnegative random number.
(Inherited from Random.)
Public methodNext(Int32)
Returns a nonnegative pseudorandom int.
(Overrides RandomNext(Int32).)
Public methodNext(Int32, Int32)
Returns a nonnegative pseudorandom int in the specified range.
(Overrides RandomNext(Int32, Int32).)
Public methodNextBeta
Generate a pseudorandom number from a beta distribution.
Public methodNextBinomial
Generate a pseudorandom number from a Binomial distribution.
Public methodNextBytes
Fills the elements of a specified array of bytes with random numbers.
(Inherited from Random.)
Public methodNextCauchy
Generates a pseudorandom number from a Cauchy distribution.
Public methodNextChiSquared
Generates a pseudorandom number from a Chi-squared distribution.
Public methodNextDouble
Generates the next pseudorandom number.
(Overrides RandomNextDouble.)
Public methodNextExponential
Generates a pseudorandom number from a standard exponential distribution.
Public methodNextExponentialMix
Generate a pseudorandom number from a mixture of two exponential distributions.
Public methodNextExtremeValue
Generate a pseudorandom number from an extreme value distribution.
Public methodNextF
Generate a pseudorandom number from the F distribution.
Public methodNextFloat
Generates the next pseudorandom number.
Public methodNextGamma
Generates a pseudorandom number from a standard gamma distribution.
Public methodNextGaussianCopula(Cholesky)
Generate pseudorandom numbers from a Gaussian Copula distribution.
Public methodNextGaussianCopula(Int32, Cholesky) Obsolete.
Generate pseudorandom numbers from a Gaussian Copula distribution.
Public methodNextGeometric
Generate a pseudorandom number from a geometric distribution.
Public methodNextHypergeometric
Generate a pseudorandom number from a hypergeometric distribution.
Public methodNextLogarithmic
Generate a pseudorandom number from a logarithmic distribution.
Public methodNextLogNormal
Generate a pseudorandom number from a lognormal distribution.
Public methodNextMultivariateNormal(Cholesky)
Generate pseudorandom numbers from a multivariate normal distribution.
Public methodNextMultivariateNormal(Int32, Cholesky) Obsolete.
Generate pseudorandom numbers from a multivariate normal distribution.
Public methodNextNegativeBinomial
Generate a pseudorandom number from a negative Binomial distribution.
Public methodNextNormal
Generate a pseudorandom number from a standard normal distribution using an inverse CDF method.
Public methodNextNormalAR
Generate a pseudorandom number from a standard normal distribution using an acceptance/rejection method.
Public methodNextPoisson
Generate a pseudorandom number from a Poisson distribution.
Public methodNextRayleigh
Generate a pseudorandom number from a Rayleigh distribution.
Public methodNextStudentsT
Generate a pseudorandom number from a Student's t distribution.
Public methodNextStudentsTCopula(Double, Cholesky)
Generate pseudorandom numbers from a Student's t Copula distribution.
Public methodNextStudentsTCopula(Int32, Double, Cholesky) Obsolete.
Generate pseudorandom numbers from a Student's t Copula distribution.
Public methodNextTriangular
Generate a pseudorandom number from a triangular distribution on the interval (0,1).
Public methodNextVonMises
Generate a pseudorandom number from a von Mises distribution.
Public methodNextWeibull
Generate a pseudorandom number from a Weibull distribution.
Public methodNextZigguratNormalAR
Generates pseudorandom numbers using the Ziggurat method.
Protected methodSample
Returns a random number between 0.0 and 1.0.
(Inherited from Random.)
Public methodSkip
Resets the seed to skip ahead in the base linear congruential generator.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Properties
  NameDescription
Public propertyMultiplier
The multiplier for a linear congruential random number generator.
Public propertyNumberOfProcessors
Perform the parallel calculations with the maximum possible number of processors set to NumberOfProcessors.
Top
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.

See Also