edu.rit.numeric
Class BernoulliPrng
- java.lang.Object
-
- edu.rit.numeric.BernoulliPrng
-
public class BernoulliPrng extends java.lang.ObjectClass BernoulliPrng provides a pseudorandom number generator (PRNG) that generates random values of type boolean. The probability of the value true (heads) is p, specified to the constructor. The probability of the value false (tails) is q = 1 − p.
-
-
Constructor Summary
Constructors Constructor and Description BernoulliPrng(Random theUniformPrng)Construct a new Bernoulli PRNG with heads probability = 0.5.BernoulliPrng(Random theUniformPrng, double p)Construct a new Bernoulli PRNG with the given heads probability.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleannext()Returns the next random value.
-
-
-
Constructor Detail
-
BernoulliPrng
public BernoulliPrng(Random theUniformPrng)
Construct a new Bernoulli PRNG with heads probability = 0.5.- Parameters:
theUniformPrng- The underlying uniform PRNG.- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if theUniformPrng is null.
-
BernoulliPrng
public BernoulliPrng(Random theUniformPrng, double p)
Construct a new Bernoulli PRNG with the given heads probability.- Parameters:
theUniformPrng- The underlying uniform PRNG.p- Heads probability, 0 ≤ p ≤ 1.- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if theUniformPrng is null.java.lang.IllegalArgumentException- (unchecked exception) Thrown if p < 0 or p > 1.
-
-
DMelt 3.0 © DataMelt by jWork.ORG