SSJ
V. labo.

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

HypergeometricGen

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 = $\displaystyle \htmax$(0, k - l + m),...,$\displaystyle \htmin$(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 < ml and 0 < kl.

The generation method is inversion using the chop-down algorithm[#!sKAC85a!#]


Constructor Summary
HypergeometricGen(RandomStream s, HypergeometricDist dist)
          .
HypergeometricGen(RandomStream s, int m, int l, int k)
          .
 
Method Summary
 int getK()
          .
 int getL()
          .
 int getM()
          .
static int nextInt(RandomStream s, int m, int l, int k)
          .
 
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)
. \begin{tabb}Creates a hypergeometric generator with
 parameters $m = $~\texttt{m}, $l = $~\texttt{l} and $k = $~\texttt{k},
 using stream \texttt{s}.
 \end{tabb}


HypergeometricGen

public HypergeometricGen(RandomStream s,
                         HypergeometricDist dist)
. \begin{tabb}Creates a new generator for distribution \texttt{dist},
 using stream \texttt{s}.
 \end{tabb}

Method Detail

nextInt

public static int nextInt(RandomStream s,
                          int m,
                          int l,
                          int k)
. \begin{tabb}
 Generates a new variate from the {\em hypergeometric\/} distributi...
 ...}, $l = $~\texttt{l} and $k = $~\texttt{k},
 using stream \texttt{s}.
 \end{tabb}


getM

public int getM()
. \begin{tabb}
 Returns the $m$\ associated with this object.
 \end{tabb}


getL

public int getL()
. \begin{tabb}
 Returns the $l$\ associated with this object.
 \end{tabb}


getK

public int getK()
. \begin{tabb}
 Returns the $k$\ associated with this object.
 \end{tabb}

 


SSJ
V. labo.

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