Class Bernoulli

java.lang.Object
eduni.distributions.Generator
eduni.distributions.Bernoulli
All Implemented Interfaces:
DiscreteGenerator, Seedable

public class Bernoulli extends Generator implements DiscreteGenerator
A random number generator based on the Bernoulli distribution.
  • Constructor Details

    • Bernoulli

      public Bernoulli(double prob)
      the seed is automatically provided by the SeedGenerator
      Parameters:
      prob - The probability of success
    • Bernoulli

      public Bernoulli(double prob, long seed)
      The constructor with which a specific seed is set for the random number generator
      Parameters:
      prob - The probability of success
      seed - The initial seed for the generator, two instances with the same seed will generate the same sequence of numbers
  • Method Details

    • sample

      public long sample()
      Generate a new random number.
      Specified by:
      sample in interface DiscreteGenerator
      Returns:
      The next random number in the sequence
    • toString

      public String toString()
      Overrides:
      toString in class Object