Class Binomial

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

public class Binomial extends Generator implements DiscreteGenerator
A random number generator based on the Binomial distribution.
  • Field Summary

    Fields inherited from class Generator

    distrib
    Modifier and Type
    Field
    Description
    protected Distributions
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Binomial(double prob, int trials)
    the seed is automatically provided by the SeedGenerator
    Binomial(double prob, int trials, long seed)
    The constructor with which a specific seed is set for the random number generator
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Generate a new random number.
     

    Methods inherited from class Generator

    getSeed, reseed, setSeed
    Modifier and Type
    Method
    Description
    long
    Get the random number generator's seed.
    void
    Get another seed well-spaced (from the default SeedGenerator)
    void
    setSeed(long seed)
    Set the random number generator's seed.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Binomial

      public Binomial(double prob, int trials)
      the seed is automatically provided by the SeedGenerator
      Parameters:
      prob - The probability of success in a trial
      trials - The number of trials
    • Binomial

      public Binomial(double prob, int trials, long seed)
      The constructor with which a specific seed is set for the random number generator
      Parameters:
      prob - The probability of success
      trials - The number of trials
      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