SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.randvar.BinomialGen Class Reference

This class implements random variate generators for the binomial distribution. More...

Inheritance diagram for umontreal.ssj.randvar.BinomialGen:
umontreal.ssj.randvar.RandomVariateGenInt umontreal.ssj.randvar.RandomVariateGen umontreal.ssj.randvar.BinomialConvolutionGen

Public Member Functions

 BinomialGen (RandomStream s, int n, double p)
 Creates a binomial random variate generator with parameters \(n\) and \(p\), using stream s.
 BinomialGen (RandomStream s, BinomialDist dist)
 Creates a random variate generator for the binomial distribution dist and the random stream s.
int getN ()
 Returns the parameter \(n\) of this object.
double getP ()
 Returns the parameter \(p\) of this object.
Public Member Functions inherited from umontreal.ssj.randvar.RandomVariateGenInt
 RandomVariateGenInt (RandomStream s, DiscreteDistributionInt dist)
 Creates a new random variate generator for the discrete distribution dist, using stream s.
int nextInt ()
 Generates a random number (an integer) from the discrete distribution contained in this object.
void nextArrayOfInt (int[] v, int start, int n)
 Generates n random numbers from the discrete distribution contained in this object.
int[] nextArrayOfInt (int n)
 Generates n random numbers from the discrete distribution contained in this object, and returns them in a new array of size n.
DiscreteDistributionInt getDistribution ()
 Returns the umontreal.ssj.probdist.DiscreteDistributionInt used by this generator.
Public Member Functions inherited from umontreal.ssj.randvar.RandomVariateGen
 RandomVariateGen (RandomStream s, Distribution dist)
 Creates a new random variate generator from the distribution dist, using stream s.
double nextDouble ()
 Generates a random number from the continuous distribution contained in this object.
void nextArrayOfDouble (double[] v, int start, int n)
 Generates n random numbers from the continuous distribution contained in this object.
double[] nextArrayOfDouble (int n)
 Generates n random numbers from the continuous distribution contained in this object, and returns them in a new array of size n.
RandomStream getStream ()
 Returns the umontreal.ssj.rng.RandomStream used by this generator.
void setStream (RandomStream stream)
 Sets the umontreal.ssj.rng.RandomStream used by this generator to stream.
String toString ()
 Returns a String containing information about the current generator.

Static Public Member Functions

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.

Protected Member Functions

void setParams (int n, double p)
 Sets the parameter \(n\) and \(p\) of this object.

Detailed Description

This class implements random variate generators for the binomial distribution.

It has parameters \(n\) and \(p\) with mass function

\[ p(x) = {n \choose x} p^x (1-p)^{n-x} = \frac{n!}{x!(n-x)!}\; p^x (1-p)^{n-x} \qquad\mbox{for } x=0,1,2,…, n \tag{fmass-binomial} \]

where \(n\) is a positive integer, and \(0\le p\le1\).

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

    <div class="SSJ-bigskip"></div>

Definition at line 46 of file BinomialGen.java.

Constructor & Destructor Documentation

◆ BinomialGen() [1/2]

umontreal.ssj.randvar.BinomialGen.BinomialGen ( RandomStream s,
int n,
double p )

Creates a binomial random variate generator with parameters \(n\) and \(p\), using stream s.

Definition at line 54 of file BinomialGen.java.

◆ BinomialGen() [2/2]

umontreal.ssj.randvar.BinomialGen.BinomialGen ( RandomStream s,
BinomialDist dist )

Creates a random variate generator for the binomial distribution dist and the random stream s.

Definition at line 63 of file BinomialGen.java.

Member Function Documentation

◆ getN()

int umontreal.ssj.randvar.BinomialGen.getN ( )

Returns the parameter \(n\) of this object.

Definition at line 80 of file BinomialGen.java.

◆ getP()

double umontreal.ssj.randvar.BinomialGen.getP ( )

Returns the parameter \(p\) of this object.

Definition at line 87 of file BinomialGen.java.

◆ nextInt()

int umontreal.ssj.randvar.BinomialGen.nextInt ( RandomStream s,
int n,
double p )
static

Generates a new integer from the binomial distribution with parameters \(n = \) n and \(p = \) p, using the given stream s.

Reimplemented in umontreal.ssj.randvar.BinomialConvolutionGen.

Definition at line 73 of file BinomialGen.java.

◆ setParams()

void umontreal.ssj.randvar.BinomialGen.setParams ( int n,
double p )
protected

Sets the parameter \(n\) and \(p\) of this object.

Definition at line 94 of file BinomialGen.java.


The documentation for this class was generated from the following file: