Class RandomEvent

java.lang.Object
ch.epfl.cs107.play.math.random.RandomEvent

public final class RandomEvent extends Object
Random Event implement notion of Bernoulli experiment with probability p of success
  • Constructor Summary

    Constructors
    Constructor
    Description
    Random Constructor for Bernoulli experiment (i.e p is selected randomly) Notice: the random event can happen multiple times
    RandomEvent(float p)
    Default Bernoulli Experiment Constructor Notice: by default the event can happen multiple times
    RandomEvent(float p, boolean onlyOnce)
    Extended Bernoulli Experiment Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Run the Bernoulli experiment and return if it succeed
    int
    nextInt(int min, int max)
    Random integer generator tool: Generate an int between the two given bounds

    Methods inherited from class java.lang.Object

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

    • RandomEvent

      public RandomEvent(float p)
      Default Bernoulli Experiment Constructor Notice: by default the event can happen multiple times
      Parameters:
      p - (float): the probability of success
    • RandomEvent

      public RandomEvent(float p, boolean onlyOnce)
      Extended Bernoulli Experiment Constructor
      Parameters:
      p - (float): the probability of success
      onlyOnce - (boolean): Specify if event can happen only once
    • RandomEvent

      public RandomEvent()
      Random Constructor for Bernoulli experiment (i.e p is selected randomly) Notice: the random event can happen multiple times
  • Method Details

    • happend

      public boolean happend()
      Run the Bernoulli experiment and return if it succeed
      Returns:
      (boolean): true if the experiment succeed, false otherwise
    • nextInt

      public int nextInt(int min, int max)
      Random integer generator tool: Generate an int between the two given bounds
      Parameters:
      min - (int): Low bound, inclusive
      max - (int): High bound, exclusive
      Returns:
      (int): between [min, max)