public class Binomial extends Object implements BinomialLike
p(x) = k * p^k * (1-p)^(n-k) with k = n! / (k! * (n-k)!).
Instance methods operate on a user supplied uniform random number generator; they are unsynchronized.
Implementation: High performance implementation. Acceptance Rejection/Inversion method. This is a port of RandBinomial used in CLHEP 1.4.0 (C++). CLHEP's implementation is, in turn, based on
V. Kachitvichyanukul, B.W. Schmeiser (1988): Binomial random variate generation, Communications of the ACM 31, 216-222.
| Modifier and Type | Field and Description |
|---|---|
protected RandomGenerator |
randomGenerator |
| Constructor and Description |
|---|
Binomial(RandomGenerator randomGenerator)
Constructs a binomial distribution.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
generateBinomial(int n,
double p)
*
Binomial-Distribution - Acceptance Rejection/Inversion *
*
*
Acceptance Rejection method combined with Inversion for *
generating Binomial random numbers with parameters *
n (number of trials) and p (probability of success).
|
int |
nextInt(int n,
double p)
Returns a random number from the distribution with the given parameters n and p; bypasses the internal state.
|
protected final RandomGenerator randomGenerator
public Binomial(RandomGenerator randomGenerator)
randomGenerator - a uniform random number generator.protected int generateBinomial(int n,
double p)
public int nextInt(int n,
double p)
nextInt in interface BinomialLiken - the number of trialsp - the probability of success.Copyright © 2020. All rights reserved.