SSJ
V. 1.2.5.

umontreal.iro.lecuyer.randvar
Class BinomialGen

java.lang.Object
  extended by umontreal.iro.lecuyer.randvar.RandomVariateGen
      extended by umontreal.iro.lecuyer.randvar.RandomVariateGenInt
          extended by umontreal.iro.lecuyer.randvar.BinomialGen
Direct Known Subclasses:
BinomialConvolutionGen

public class BinomialGen
extends RandomVariateGenInt

This class implements random variate generators for the binomial distribution. It has parameters n and p with mass function

p(x) = nCr(n, x)px(1 - p)n-x = n!/(x!(n - x)!)  px(1 - p)n-x        for x = 0, 1, 2,..., n

where nCr(n, x) is the number of combinations of x objects among n, n is a positive integer, and 0 <= p <= 1.

No local copy of the parameters n and p is maintained in this class. The (non-static) nextInt method simply calls inverseF on the distribution.


Constructor Summary
BinomialGen(RandomStream s, BinomialDist dist)
          Creates a new random variate generator for the binomial distribution dist and the random 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 n, double p)
          Generates a new integer from the binomial distribution with parameters n = n and p = p, using the given 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

BinomialGen

public BinomialGen(RandomStream s,
                   BinomialDist dist)
Creates a new random variate generator for the binomial distribution dist and the random 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 n,
                          double p)
Generates a new integer from the binomial distribution with parameters n = n and p = p, using the given stream s.


SSJ
V. 1.2.5.

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