Enum Class DistributedRandom.ReductionMode

java.lang.Object
java.lang.Enum<DistributedRandom.ReductionMode>
com.github.tommyettinger.random.DistributedRandom.ReductionMode
All Implemented Interfaces:
Serializable, Comparable<DistributedRandom.ReductionMode>, Constable
Enclosing class:
DistributedRandom

public static enum DistributedRandom.ReductionMode extends Enum<DistributedRandom.ReductionMode>
One of two possible modes this can use to limit the range of a Distribution. FRACTION simply gets the fractional part of a distribution by subtracting the floor from a result. CLAMP uses Math.min(double, double) and Math.max(double, double) to cap the values at both ends, inclusive on 0.0 and exclusive on 1.0 .
  • Enum Constant Details

    • FRACTION

      public static final DistributedRandom.ReductionMode FRACTION
      Gets one distributed double, gets the portion after the decimal point, and only uses that.
    • CLAMP

      public static final DistributedRandom.ReductionMode CLAMP
      Gets one distributed double and clamps it to 0.0 if it is less than 0.0, or to 0.9999999999999999 if it is 0.9999999999999999 or greater, then uses that.
    • REJECT

      public static final DistributedRandom.ReductionMode REJECT
      Repeatedly attempts to get one distributed double, check if it is between 0.0 inclusive and 1.0 exclusive, and either return it if it is within range or get another distributed double and try again. This is not guaranteed to complete for all distributions! While this can be the most correct ReductionMode for some distributions, use it with caution. Make sure the Distribution.getMinimum() and Distribution.getMaximum() allow results to be returned between 0 and 1.
  • Method Details

    • values

      public static DistributedRandom.ReductionMode[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static DistributedRandom.ReductionMode valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • applyAsDouble

      public abstract double applyAsDouble(Distribution dist)