umontreal.iro.lecuyer.randvar
Class BinomialGen
- java.lang.Object
-
- umontreal.iro.lecuyer.randvar.RandomVariateGen
-
- umontreal.iro.lecuyer.randvar.RandomVariateGenInt
-
- 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 functionp(x) = nCr(n, x)px(1 - p)n-x = n!/(x!(n - x)!) px(1 - p)n-x for x = 0, 1, 2,..., nwhere 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
Constructors Constructor and Description 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description intgetN()Returns the parameter n of this object.doublegetP()Returns the parameter p of this object.static intnextInt(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
-
-
-
-
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.
-
-
DMelt 3.0 © DataMelt by jWork.ORG