SSJ  3.2.1
Stochastic Simulation in Java
 All Classes Namespaces Functions Variables Pages
Classes
Package umontreal.ssj.randvar

Generating Non-Uniform Random Numbers. More...

Classes

class  BernoulliGen
 This class implements random variate generators for the Bernoulli distribution (see class umontreal.ssj.probdist.BernoulliDist ). More...
 
class  BetaGen
 This class implements random variate generators with the beta distribution with shape parameters \(\alpha> 0\) and \(\beta> 0\), over the interval \((a,b)\), where \(a < b\). More...
 
class  BetaRejectionLoglogisticGen
 Implements Beta random variate generators using the rejection method with log-logistic envelopes from [30] . More...
 
class  BetaStratifiedRejectionGen
 This class implements Beta random variate generators using the stratified rejection/patchwork rejection method from [179], [190] . More...
 
class  BetaSymmetricalBestGen
 This class implements symmetrical beta random variate generators using Devroye’s one-liner method. More...
 
class  BetaSymmetricalGen
 This class implements random variate generators with the symmetrical beta distribution with shape parameters \(\alpha= \beta\), over the interval \((0,1)\). More...
 
class  BetaSymmetricalPolarGen
 This class implements symmetrical beta random variate generators using Ulrich’s polar method [199] . More...
 
class  BinomialConvolutionGen
 Implements binomial random variate generators using the convolution method. More...
 
class  BinomialGen
 This class implements random variate generators for the binomial distribution. More...
 
class  CauchyGen
 This class implements random variate generators for the Cauchy distribution. More...
 
class  ChiGen
 This class implements random variate generators for the chi distribution. More...
 
class  ChiRatioOfUniformsGen
 This class implements Chi random variate generators using the ratio of uniforms method with shift. More...
 
class  ChiSquareGen
 This class implements random variate generators with the chi square distribution with \(n>0\) degrees of freedom. More...
 
class  ChiSquareNoncentralGamGen
 This class implements noncentral chi square random variate generators using the additive property of the noncentral chi square distribution [104] . More...
 
class  ChiSquareNoncentralGen
 This class implements random variate generators for the noncentral chi square distribution with \(\nu> 0\) degrees of freedom and noncentrality parameter \(\lambda> 0\). More...
 
class  ChiSquareNoncentralPoisGen
 This class implements noncentral chi square random variate generators using Poisson and central chi square generators. More...
 
class  ConstantGen
 This class implements a random variate generator that returns a constant value. More...
 
class  ErlangConvolutionGen
 This class implements Erlang random variate generators using the convolution method. More...
 
class  ErlangGen
 This class implements random variate generators for the Erlang distribution with parameters \(k > 0\) and \(\lambda> 0\). More...
 
class  ExponentialGen
 This class implements random variate generators for the exponential distribution. More...
 
class  ExponentialInverseFromDensityGen
 This class implements exponential random variate generators using numerical inversion of the exponential density as described in [40] . More...
 
class  ExtremeValueGen
 This class has been replaced by GumbelGen . More...
 
class  FatigueLifeGen
 This class implements random variate generators for the fatigue life distribution [18]  with location parameter \(\mu\), scale parameter \(\beta\) and shape parameter \(\gamma\). More...
 
class  FisherFGen
 This class implements random variate generators for the Fisher F distribution with \(n\) and \(m\) degrees of freedom, where \(n\) and \(m\) are positive integers. More...
 
class  FNoncentralGen
 This class implements random variate generators for the noncentral F-distribution. More...
 
class  FoldedNormalGen
 This class implements methods for generating random variates from the folded normal distribution with parameters \(\mu\ge0\) and \(\sigma> 0\). More...
 
class  FrechetGen
 This class implements methods for generating random variates from the Fréchet distribution, with location parameter \(\delta\), scale parameter \(\beta> 0\), and shape parameter \(\alpha> 0\), where we use the notation \(z = (x-\delta)/\beta\). More...
 
class  GammaAcceptanceRejectionGen
 This class implements gamma random variate generators using a method that combines acceptance-rejection with acceptance-complement, and proposed in [1], [3] . More...
 
class  GammaGen
 This class implements random variate generators for the gamma distribution. More...
 
class  GammaRejectionLoglogisticGen
 This class implements gamma random variate generators using a rejection method with loglogistic envelopes, from [29] . More...
 
class  GeometricGen
 This class implements a random variate generator for the geometric distribution. More...
 
class  GumbelGen
 This class implements methods for generating random variates from the Gumbel distribution. More...
 
class  HalfNormalGen
 This class implements methods for generating random variates from the half-normal distribution with parameters \(\mu\) and \(\sigma> 0\). More...
 
class  HyperbolicSecantGen
 This class implements random variate generators for the hyperbolic secant distribution with location parameter \(\mu\) and scale parameter \(\sigma\). More...
 
class  HypergeometricGen
 This class implements random variate generators for the hypergeometric distribution. More...
 
class  HypoExponentialGen
 This class implements random variate generators for the hypoexponential distribution (see classes umontreal.ssj.probdist.HypoExponentialDist and umontreal.ssj.probdist.HypoExponentialDistQuick in package probdist for the definition). More...
 
class  InverseFromDensityGen
 Implements a method for generating random variates by numerical inversion of an arbitrary continuous distribution when only the probability density is known [40] . More...
 
class  InverseGammaGen
 This class implements random variate generators for the inverse gamma distribution with shape parameter \(\alpha> 0\) and scale parameter \(\beta> 0\). More...
 
class  InverseGaussianGen
 This class implements random variate generators for the inverse Gaussian distribution with location parameter \(\mu> 0\) and scale parameter \(\lambda> 0\). More...
 
class  InverseGaussianMSHGen
 This class implements inverse gaussian random variate generators using the many-to-one transformation method of Michael, Schucany and Haas (MHS) [153], [44] . More...
 
class  JohnsonSBGen
 This class implements random variate generators for the Johnson \(S_B\) distribution. More...
 
class  JohnsonSLGen
 This class implements random variate generators for the Johnson \(S_L\) distribution. More...
 
class  JohnsonSUGen
 This class implements random variate generators for the Johnson \(S_U\) distribution. More...
 
class  JohnsonSystemG
 This class contains common parameters and methods for the random variate generators associated with the Johnson system of distributions [90], [88] . More...
 
class  KernelDensityGen
 This class implements random variate generators for distributions obtained via kernel density estimation methods from a set of \(n\) individual observations \(x_1,…,x_n\) [41], [42], [80], [81], [183] . More...
 
class  KernelDensityVarCorrectGen
 This class is a variant of KernelDensityGen, but with a rescaling of the empirical distribution so that the variance of the density used to generate the random variates is equal to the empirical variance, as suggested by [183] . More...
 
class  LaplaceGen
 This class implements methods for generating random variates from the Laplace distribution. More...
 
class  LogarithmicGen
 This class implements random variate generators for the (discrete) logarithmic distribution. More...
 
class  LogisticGen
 This class implements random variate generators for the logistic distribution. More...
 
class  LoglogisticGen
 This class implements random variate generators for the log-logistic distribution with shape parameter \(\alpha> 0\) and scale parameter \(\beta> 0\). More...
 
class  LognormalGen
 This class implements methods for generating random variates from the lognormal distribution. More...
 
class  LognormalSpecialGen
 Implements methods for generating random variates from the lognormal distribution using an arbitrary normal random variate generator. More...
 
class  NakagamiGen
 This class implements random variate generators for the Nakagami distribution. More...
 
class  NegativeBinomialGen
 This class implements random variate generators having the negative binomial distribution. More...
 
class  NormalACRGen
 This class implements normal random variate generators using the acceptance-complement ratio method [78] . More...
 
class  NormalBoxMullerGen
 This class implements normal random variate generators using the Box-Muller method from [21] . More...
 
class  NormalGen
 This class implements methods for generating random variates from the normal distribution \(N(\mu, \sigma)\). More...
 
class  NormalInverseFromDensityGen
 This class implements normal random variate generators using numerical inversion of the normal density as described in [40] . More...
 
class  NormalInverseGaussianGen
 This class implements random variate generators for the normal inverse gaussian ( \(\mathcal{NIG}\)) distribution. More...
 
class  NormalInverseGaussianIGGen
 This class implements a normal inverse gaussian ( \({NIG}\)) random variate generator by using a normal generator ( \(N\)) and an inverse gaussian generator ( \(IG\)), as described in the following [204], [92] . More...
 
class  NormalKindermannRamageGen
 This class implements normal random variate generators using the Kindermann-Ramage method [95] . More...
 
class  NormalPolarGen
 This class implements normal random variate generators using the polar method with rejection [149] . More...
 
class  ParetoGen
 This class implements random variate generators for one of the Pareto distributions, with parameters \(\alpha>0\) and \(\beta>0\). More...
 
class  PascalConvolutionGen
 Implements Pascal random variate generators by the convolution method (see [107] ). More...
 
class  PascalGen
 Implements Pascal random variate generators, which is a special case of the negative binomial generator with parameter \(\gamma\) equal to a positive integer. More...
 
class  Pearson5Gen
 THIS CLASS HAS BEEN RENAMED InverseGammaGen . More...
 
class  Pearson6Gen
 This class implements random variate generators for the Pearson type VI distribution with shape parameters \(\alpha_1 > 0\) and \(\alpha_2 > 0\), and scale parameter \(\beta> 0\). More...
 
class  PoissonGen
 This class implements random variate generators having the Poisson distribution. More...
 
class  PoissonTIACGen
 This class implements random variate generators having the Poisson distribution (see PoissonGen ). More...
 
class  PowerGen
 This class implements random variate generators for the power distribution with shape parameter \(c > 0\), over the interval \([a,b]\). More...
 
class  RandomVariateGen
 This is the base class for all random variate generators over the real line. More...
 
class  RandomVariateGenInt
 This is the base class for all generators of discrete random variates over the set of integers. More...
 
class  RandomVariateGenWithCache
 This class represents a random variate generator whose values are cached for more efficiency when using common random numbers. More...
 
class  RandUnuran
 This internal class provides the access point to the C package UNURAN. More...
 
class  RayleighGen
 This class implements random variate generators for the Rayleigh distribution. More...
 
class  StudentGen
 This class implements methods for generating random variates from the Student distribution with \(n>0\) degrees of freedom. More...
 
class  StudentNoncentralGen
 This class implements random variate generators for the noncentral Student-t distribution with \(n>0\) degrees of freedom and noncentrality parameter \(\delta\). More...
 
class  StudentPolarGen
 This class implements Student random variate generators using the polar method of [12] . More...
 
class  TriangularGen
 This class implements random variate generators for the triangular distribution. More...
 
class  UniformGen
 This class implements random variate generators for the (continuous) uniform distribution over the interval \((a,b)\), where \(a\) and \(b\) are real numbers with \(a < b\). More...
 
class  UniformIntGen
 This class implements a random variate generator for the uniform distribution over integers, over the interval \([i,j]\). More...
 
class  UnuranContinuous
 This class permits one to create continuous univariate generators using UNURAN via its string API. More...
 
class  UnuranDiscreteInt
 This class permits one to create a discrete univariate generator using UNURAN via its string API. More...
 
class  UnuranEmpirical
 This class permits one to create generators for empirical and quasi-empirical univariate distributions using UNURAN via its string interface. More...
 
class  UnuranException
 This type of unchecked exception is thrown when an error occurs inside the UNURAN package. More...
 
class  WeibullGen
 This class implements random variate generators for the Weibull distribution. More...
 

Detailed Description

Generating Non-Uniform Random Numbers.

This package provides a collection of classes for non-uniform random variate generation, primarily from standard distributions.

Each non-uniform random variate generator requires at least one umontreal.ssj.rng.RandomStream object (from package umontreal.ssj.rng ), used to generate the underlying uniform random numbers.

The generic classes umontreal.ssj.randvar.RandomVariateGen and umontreal.ssj.randvar.RandomVariateGenInt permit one to construct a random variate generator from a random stream and an arbitrary distribution (see interface umontreal.ssj.probdist.Distribution ). To generate random variates by inversion from an arbitrary distribution over the real numbers using a given random stream, it suffices to construct a umontreal.ssj.randvar.RandomVariateGen object with the desired (previously created) umontreal.ssj.probdist.Distribution and umontreal.ssj.rng.RandomStream objects, and then call its umontreal.ssj.randvar.RandomVariateGen.nextDouble method as many times as needed. For discrete distributions over the integers, one can construct a umontreal.ssj.randvar.RandomVariateGenInt object containing the desired umontreal.ssj.probdist.DiscreteDistributionInt and umontreal.ssj.rng.RandomStream, and call its umontreal.ssj.randvar.RandomVariateGenInt.nextInt method. By default, these generators simply call the umontreal.ssj.probdist.ContinuousDistribution.inverseF method from the specified distribution object. These two classes suffice as long as we are willing to use inversion. Here is a simple example in which we create three parallel streams of normal random variates using inversion.

Using three parallel streams of random normal variates  [normaltest]

import umontreal.ssj.rng.*;
public class normaltest
{
public static void main (String[] args) {
// Create 3 parallel streams of random numbers
RandomStream stream1 = new MRG31k3p();
RandomStream stream2 = new MRG31k3p();
RandomStream stream3 = new MRG31k3p();
// Create 3 parallel streams of normal random variates
RandomVariateGen gen1 = new NormalGen (stream1);
RandomVariateGen gen2 = new NormalGen (stream2);
RandomVariateGen gen3 = new NormalGen (stream3);
final int n = 5;
genere (gen1, n);
genere (gen2, n);
genere (gen3, n);
}
private static void genere (RandomVariateGen gen, int n) {
double u;
for (int i = 0; i < n; i++) {
u = gen.nextDouble();
System.out.printf ("%12.6f%n", u);
}
System.out.println ("----------------------");
}
}

To generate random variates by other methods than inversion, one can use specialized classes that extend umontreal.ssj.randvar.RandomVariateGen or umontreal.ssj.randvar.RandomVariateGenInt. Such classes are provided for a variety of standard discrete and continuous distributions. For example, five different subclasses implement normal random variate generators, using five different methods. One of them, the class umontreal.ssj.randvar.NormalGen, extends umontreal.ssj.randvar.RandomVariateGen directly and provides normal random variate generators based on inversion, so it does the same thing as using umontreal.ssj.randvar.RandomVariateGen with the normal distribution. The others are subclasses of umontreal.ssj.randvar.NormalGen; they implement various non-inversion normal variate generation methods. To generate random variates with a specific method, it suffices to construct an object of the appropriate subclass and then call its nextDouble method.

In most cases, the specialized classes maintain local copies of the distribution parameters and use them for variate generation. If the parameters of the contained distribution objects are later modified, this may lead to inconsistencies: the variate generator object will keep using the old values. In fact, the constructors of the specialized classes often precompute constants and tables based on these parameter values, which would have to be recomputed if the parameters are changed. On the other hand, the generic classes umontreal.ssj.randvar.RandomVariateGen and umontreal.ssj.randvar.RandomVariateGenInt call directly the inverseF method of the contained distribution object, so they will always use the new parameter values whenever the parameters in the distribution object are changed.

With some variate generation methods (e.g., the rejection method), the number of uniforms required to get a single non-uniform variate varies from one call to the next. In that case, an auxiliary stream is often used to preserve the synchronization between random variates when implementing variance-reduction methods [107] . The main random number stream is called a fixed number of times per non-uniform variate generation. If more uniform random numbers are needed, they are obtained from the auxiliary stream. For these types of generators, two umontreal.ssj.rng.RandomStream objects should be passed to the constructor. Otherwise, by default, the same stream will be used for all uniforms.

Static methods in the specialized classes allow the generation of random variates from specific distributions without constructing a umontreal.ssj.randvar.RandomVariateGen object.

This package also provides an interface to the UNURAN (Universal Non-Uniform RANdom number generators) package, a rich library of C functions designed and implemented by the ARVAG (Automatic Random VAriate Generation) project group in Vienna [140] . This interface can be used to access distributions or generation methods not available directly in SSJ. To get a UNURAN generator, it suffices to instantiate one of the UNURAN interface classes: umontreal.ssj.randvar.UnuranDiscreteInt for discrete random variates, umontreal.ssj.randvar.UnuranContinuous for continuous ones (in one dimension), and umontreal.ssj.randvar.UnuranEmpirical for quasi-empirical distributions based on experimental data. The type of distribution and its parameters are specified to UNURAN via its String API (see the UNURAN documentation). Only univariate distributions are supported because the UNURAN String API does not support the multivariate ones yet.

In the UNURAN interface classes, umontreal.ssj.randvar.RandomVariateGen.nextDouble and umontreal.ssj.randvar.RandomVariateGenInt.nextInt can be invoked as usual to generate variates, but these methods are slowed down significantly by the overhead in the interactions between code on the native side and on the Java side. When several random variates are needed, it is much more efficient to generate them in a single call, via the methods umontreal.ssj.randvar.RandomVariateGen.nextArrayOfDouble and umontreal.ssj.randvar.RandomVariateGenInt.nextArrayOfInt.