|
Uncommons Maths API (Version 1.2.3) |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.uncommons.maths.random.BinomialGenerator
public class BinomialGenerator
Discrete random sequence that follows a binomial distribution.
Constructor Summary | |
---|---|
BinomialGenerator(int n,
double p,
Random rng)
Creates a generator of binomially-distributed values from a distribution with the specified parameters. |
|
BinomialGenerator(NumberGenerator<Integer> n,
NumberGenerator<Double> p,
Random rng)
Creates a generator of binomially-distributed values. |
Method Summary | |
---|---|
Integer |
nextValue()
Generate the next binomial value from the current values of n and p. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BinomialGenerator(NumberGenerator<Integer> n, NumberGenerator<Double> p, Random rng)
Creates a generator of binomially-distributed values. The number of
trials (n) and the probability of success in each trial
(p) are determined by the provided NumberGenerator
s.
This means that the statistical parameters of this generator may change
over time. One example of where this is useful is if the n
and p generators are attached to GUI controls that allow a
user to tweak the parameters while a program is running.
To create a Binomial generator with a constant n and
p, use the BinomialGenerator(int, double, Random)
constructor instead.
n
- A NumberGenerator
that provides the number of trials for
the Binomial distribution used for the next generated value. This generator
must produce only positive values.p
- A NumberGenerator
that provides the probability of succes
in a single trial for the Binomial distribution used for the next
generated value. This generator must produce only values in the range 0 - 1.rng
- The source of randomness.public BinomialGenerator(int n, double p, Random rng)
n
- The number of trials (and therefore the maximum possible value returned
by this sequence).p
- The probability (between 0 and 1) of success in any one trial.rng
- The source of randomness used to generate the binomial values.Method Detail |
---|
public Integer nextValue()
nextValue
in interface NumberGenerator<Integer>
|
Uncommons Maths API (Version 1.2.3) |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |