Random Class |
Namespace: Imsl.Stat
The Random type exposes the following members.
Name | Description | |
---|---|---|
Random |
Constructor for the Random number generator class.
| |
Random(Int32) |
Constructor for the Random number generator class with supplied seed.
| |
Random(RandomBaseGenerator) |
Constructor for the Random number generator class with
an alternate basic number genrator.
|
Name | Description | |
---|---|---|
CanonicalCorrelation | 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. | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Next | Returns a nonnegative random number. (Inherited from Random.) | |
Next(Int32) |
Returns a nonnegative pseudorandom int.
(Overrides RandomNext(Int32).) | |
Next(Int32, Int32) |
Returns a nonnegative pseudorandom int in the specified range.
(Overrides RandomNext(Int32, Int32).) | |
NextBeta |
Generate a pseudorandom number from a beta distribution.
| |
NextBinomial |
Generate a pseudorandom number from a Binomial distribution.
| |
NextBytes | Fills the elements of a specified array of bytes with random numbers. (Inherited from Random.) | |
NextCauchy |
Generates a pseudorandom number from a Cauchy distribution.
| |
NextChiSquared |
Generates a pseudorandom number from a Chi-squared distribution.
| |
NextDouble |
Generates the next pseudorandom number.
(Overrides RandomNextDouble.) | |
NextExponential |
Generates a pseudorandom number from a standard exponential
distribution.
| |
NextExponentialMix |
Generate a pseudorandom number from a mixture of two exponential
distributions.
| |
NextExtremeValue |
Generate a pseudorandom number from an extreme value distribution.
| |
NextF |
Generate a pseudorandom number from the F distribution.
| |
NextFloat |
Generates the next pseudorandom number.
| |
NextGamma |
Generates a pseudorandom number from a standard gamma distribution.
| |
NextGaussianCopula(Cholesky) |
Generate pseudorandom numbers from a Gaussian Copula distribution.
| |
NextGaussianCopula(Int32, Cholesky) | Obsolete.
Generate pseudorandom numbers from a Gaussian Copula distribution.
| |
NextGeometric |
Generate a pseudorandom number from a geometric distribution.
| |
NextHypergeometric |
Generate a pseudorandom number from a hypergeometric distribution.
| |
NextLogarithmic |
Generate a pseudorandom number from a logarithmic distribution.
| |
NextLogNormal |
Generate a pseudorandom number from a lognormal distribution.
| |
NextMultivariateNormal(Cholesky) |
Generate pseudorandom numbers from a multivariate normal
distribution.
| |
NextMultivariateNormal(Int32, Cholesky) | Obsolete.
Generate pseudorandom numbers from a multivariate normal
distribution.
| |
NextNegativeBinomial |
Generate a pseudorandom number from a negative Binomial distribution.
| |
NextNormal |
Generate a pseudorandom number from a standard normal distribution
using an inverse CDF method.
| |
NextNormalAR |
Generate a pseudorandom number from a standard normal distribution
using an acceptance/rejection method.
| |
NextPoisson |
Generate a pseudorandom number from a Poisson distribution.
| |
NextRayleigh |
Generate a pseudorandom number from a Rayleigh distribution.
| |
NextStudentsT |
Generate a pseudorandom number from a Student's t distribution.
| |
NextStudentsTCopula(Double, Cholesky) |
Generate pseudorandom numbers from a Student's t Copula
distribution.
| |
NextStudentsTCopula(Int32, Double, Cholesky) | Obsolete.
Generate pseudorandom numbers from a Student's t Copula
distribution.
| |
NextTriangular |
Generate a pseudorandom number from a triangular distribution on
the interval (0,1).
| |
NextVonMises |
Generate a pseudorandom number from a von Mises distribution.
| |
NextWeibull |
Generate a pseudorandom number from a Weibull distribution.
| |
NextZigguratNormalAR |
Generates pseudorandom numbers using the Ziggurat method.
| |
Sample | Returns a random number between 0.0 and 1.0. (Inherited from Random.) | |
Skip |
Resets the seed to skip ahead in the base linear congruential
generator.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
Multiplier |
The multiplier for a linear congruential random number generator.
| |
NumberOfProcessors |
Perform the parallel calculations with the maximum possible number of
processors set to NumberOfProcessors.
|
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
Each is then scaled into the unit interval (0,1). If the multiplier, c, is a primitive root modulo (which is a prime), then the generator will have a maximal period of . 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 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 of the correlation matrix can then be extracted by averaging the products 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.