SSJ
V. 2.6.

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.

The (non-static) nextInt method simply calls inverseF on the distribution.


Constructor Summary
BinomialGen(RandomStream s, BinomialDist dist)
          Creates a random variate generator for the binomial distribution dist and the random stream s.
BinomialGen(RandomStream s, int n, double p)
          Creates a binomial random variate generator with parameters n and p, using stream s.
 
Method Summary
 int getN()
          Returns the parameter n of this object.
 double getP()
          Returns the parameter p of 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
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

BinomialGen

public BinomialGen(RandomStream s,
                   int n,
                   double p)
Creates a binomial random variate generator with parameters n and p, using stream s.


BinomialGen

public BinomialGen(RandomStream s,
                   BinomialDist dist)
Creates a random variate generator for the binomial distribution dist and the random stream s.

Method Detail

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.


getN

public int getN()
Returns the parameter n of this object.


getP

public double getP()
Returns the parameter p of this object.


SSJ
V. 2.6.

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