Documentation of 'edu.rit.numeric.BernoulliPrng' Java class
BernoulliPrng
edu.rit.numeric

Class BernoulliPrng



  • public class BernoulliPrng
    extends java.lang.Object
    Class 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
      boolean next()
      Returns the next random value.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.
    • Method Detail

      • next

        public boolean next()
        Returns the next random value. True (heads) is returned with probability p, false (tails) is returned with probability 1 − p.
        Returns:
        Random value.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.