public class BernoulliTrial extends Object implements RandomNumberGenerator
Constructor and Description |
---|
BernoulliTrial(RandomNumberGenerator rng,
double p)
Creates a new instance that uses the given
RandomNumberGenerator to do the trial. |
Modifier and Type | Method and Description |
---|---|
double |
nextDouble()
Get the next random
double , which is either 1 (success) or 0 (failure). |
boolean |
nextLogTrial()
Performs a Bernoulli trial that succeeds with probability ep.
|
static boolean |
nextLogTrial(RandomNumberGenerator rng,
double p)
Performs a Bernoulli trial that succeeds with probability ep.
|
boolean |
nextTrial()
Performs a Bernoulli trial that succeeds with probability p.
|
static boolean |
nextTrial(RandomNumberGenerator rng,
double p)
Performs a Bernoulli trial that succeeds with probability p.
|
void |
seed(long... seeds)
Seed the random number/vector/scenario generator to produce repeatable experiments.
|
public BernoulliTrial(RandomNumberGenerator rng, double p)
RandomNumberGenerator
to do the trial.rng
- the random number generator that is to be usedp
- the success probabilitypublic static boolean nextTrial(RandomNumberGenerator rng, double p)
rng
- a random number generatorp
- a success probabilitytrue
if the trial succeededpublic boolean nextTrial()
true
if the trial succeededpublic static boolean nextLogTrial(RandomNumberGenerator rng, double p)
rng
- a random number generatorp
- the log of a success probabilitytrue
if the trial succeededpublic boolean nextLogTrial()
true
if the trial succeededpublic double nextDouble()
double
, which is either 1 (success) or 0 (failure).nextDouble
in interface RandomNumberGenerator
Copyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.