SSJ
V. 2.6.

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.
HypergeometricGen(RandomStream s, int m, int l, int k)
          Creates a hypergeometric generator with parameters m = m, l = l and k = k, using stream s.
 
Method Summary
 int getK()
          Returns the k associated with this object.
 int getL()
          Returns the l associated with this object.
 int getM()
          Returns the m associated with 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
getDistribution, nextArrayOfInt, nextInt
 
Methods inherited from class umontreal.iro.lecuyer.randvar.RandomVariateGen
getStream, nextArrayOfDouble, nextDouble, setStream, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HypergeometricGen

public HypergeometricGen(RandomStream s,
                         int m,
                         int l,
                         int k)
Creates a hypergeometric generator with parameters m = m, l = l and k = k, using stream s.


HypergeometricGen

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

Method Detail

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.


getM

public int getM()
Returns the m associated with this object.


getL

public int getL()
Returns the l associated with this object.


getK

public int getK()
Returns the k associated with this object.


SSJ
V. 2.6.

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