umontreal.iro.lecuyer.randvar
Class RandomVariateGenInt
- java.lang.Object
-
- umontreal.iro.lecuyer.randvar.RandomVariateGen
-
- umontreal.iro.lecuyer.randvar.RandomVariateGenInt
-
- Direct Known Subclasses:
- BernoulliGen, BinomialGen, GeometricGen, HypergeometricGen, LogarithmicGen, NegativeBinomialGen, PascalGen, PoissonGen, UniformIntGen, UnuranDiscreteInt
public class RandomVariateGenInt extends RandomVariateGen
This is the base class for all generators of discrete random variates over the set of integers. Similar toRandomVariateGen, except that the generators produce integers, via thenextIntmethod, instead of real numbers.
-
-
Constructor Summary
Constructors Constructor and Description RandomVariateGenInt(RandomStream s, DiscreteDistributionInt dist)Creates a new random variate generator for the discrete distribution dist, using stream s.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description DiscreteDistributionIntgetDistribution()Returns theDiscreteDistributionIntused by this generator.voidnextArrayOfInt(int[] v, int start, int n)Generates n random numbers from the discrete distribution contained in this object.intnextInt()Generates a random number (an integer) from the discrete distribution contained in this object.-
Methods inherited from class umontreal.iro.lecuyer.randvar.RandomVariateGen
getStream, nextArrayOfDouble, nextDouble, setStream, toString
-
-
-
-
Constructor Detail
-
RandomVariateGenInt
public RandomVariateGenInt(RandomStream s, DiscreteDistributionInt dist)
Creates a new random variate generator for the discrete distribution dist, using stream s.- Parameters:
s- random stream used for generating uniformsdist- discrete distribution object of the generated values
-
-
Method Detail
-
nextInt
public int nextInt()
Generates a random number (an integer) from the discrete distribution contained in this object. By default, this method uses inversion by calling the inverseF method of the distribution object. Alternative generating methods are provided in subclasses.- Returns:
- the generated value
-
nextArrayOfInt
public void nextArrayOfInt(int[] v, int start, int n)Generates n random numbers from the discrete distribution contained in this object. The results are stored into the array v, starting from index start. By default, this method callsnextInt()n times, but one can reimplement it in subclasses for better efficiency.- Parameters:
v- array into which the variates will be storedstart- starting index, in v, of the new variatesn- number of variates being generated
-
getDistribution
public DiscreteDistributionInt getDistribution()
Returns theDiscreteDistributionIntused by this generator.- Overrides:
getDistributionin classRandomVariateGen- Returns:
- the distribution associated to that object
-
-
DMelt 3.0 © DataMelt by jWork.ORG