SSJ
V. 1.2.5.

umontreal.iro.lecuyer.randvar
Class HypergeometricGen

java.lang.Object
  extended by umontreal.iro.lecuyer.randvar.RandomVariateGen
      extended by umontreal.iro.lecuyer.randvar.RandomVariateGenInt
          extended by umontreal.iro.lecuyer.randvar.HypergeometricGen

public class HypergeometricGen
extends RandomVariateGenInt

This class implements random variate generators for the hypergeometric distribution. Its mass function is

p(x) = nCr(m, x)nCr(l - m, k - x)/nCr(l, k)        for x = max(0, k - l + m),..., min(k, m)

where nCr(n, x) is the number of possible combinations when choosing x elements among a set of n elements, m, l and k are integers that satisfy 0 < m <= l and 0 < k <= l.

The generation method is inversion using the chop-down algorithm


Constructor Summary
HypergeometricGen(RandomStream s, HypergeometricDist dist)
          Creates a new generator for distribution dist, using stream s.
 
Method Summary
 int nextInt()
          Generates a random number (an integer) from the discrete distribution contained in this object.
static int nextInt(RandomStream s, int m, int l, int k)
          Generates a new variate from the hypergeometric distribution with parameters m = m, l = l and k = k, using stream s.
 
Methods inherited from class umontreal.iro.lecuyer.randvar.RandomVariateGenInt
nextArrayOfInt
 
Methods inherited from class umontreal.iro.lecuyer.randvar.RandomVariateGen
getDistribution, getStream, nextArrayOfDouble, nextDouble, setStream
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HypergeometricGen

public HypergeometricGen(RandomStream s,
                         HypergeometricDist dist)
Creates a new generator for distribution dist, using stream s.

Method Detail

nextInt

public int nextInt()
Description copied from class: RandomVariateGenInt
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.

Overrides:
nextInt in class RandomVariateGenInt
Returns:
the generated value

nextInt

public static int nextInt(RandomStream s,
                          int m,
                          int l,
                          int k)
Generates a new variate from the hypergeometric distribution with parameters m = m, l = l and k = k, using stream s.


SSJ
V. 1.2.5.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.