Class ImmutableEmpiricalDistribution

java.lang.Object
io.github.ai4ci.util.ImmutableEmpiricalDistribution
All Implemented Interfaces:
Abstraction.Distribution, EmpiricalDistribution, Serializable

@ParametersAreNonnullByDefault @Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableEmpiricalDistribution extends Object implements EmpiricalDistribution
Immutable implementation of EmpiricalDistribution.

Use the builder to create immutable instances: ImmutableEmpiricalDistribution.builder().

See Also:
  • Method Details

    • getMinimum

      public double getMinimum()
      Specified by:
      getMinimum in interface EmpiricalDistribution
      Returns:
      The value of the minimum attribute
    • getMaximum

      public double getMaximum()
      Specified by:
      getMaximum in interface EmpiricalDistribution
      Returns:
      The value of the maximum attribute
    • getX

      public double[] getX()
      Specified by:
      getX in interface EmpiricalDistribution
      Returns:
      A cloned x array
    • getCumulativeProbability

      public double[] getCumulativeProbability()
      Specified by:
      getCumulativeProbability in interface EmpiricalDistribution
      Returns:
      A cloned cumulativeProbability array
    • getQuantile

      public SplineInterpolator getQuantile()
      Specified by:
      getQuantile in interface EmpiricalDistribution
      Returns:
      The computed-at-construction value of the quantile attribute
    • withMinimum

      public final ImmutableEmpiricalDistribution withMinimum(double value)
      Copy the current immutable object by setting a value for the minimum attribute. A value strict bits equality used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for minimum
      Returns:
      A modified copy of the this object
    • withMaximum

      public final ImmutableEmpiricalDistribution withMaximum(double value)
      Copy the current immutable object by setting a value for the maximum attribute. A value strict bits equality used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for maximum
      Returns:
      A modified copy of the this object
    • withX

      public final ImmutableEmpiricalDistribution withX(double... elements)
      Copy the current immutable object with elements that replace the content of x. The array is cloned before being saved as attribute values.
      Parameters:
      elements - The non-null elements for x
      Returns:
      A modified copy of this object
    • withCumulativeProbability

      public final ImmutableEmpiricalDistribution withCumulativeProbability(double... elements)
      Copy the current immutable object with elements that replace the content of cumulativeProbability. The array is cloned before being saved as attribute values.
      Parameters:
      elements - The non-null elements for cumulativeProbability
      Returns:
      A modified copy of this object
    • equals

      public boolean equals(@Nullable Object another)
      This instance is equal to all instances of ImmutableEmpiricalDistribution that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: minimum, maximum, x, cumulativeProbability, quantile.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value EmpiricalDistribution with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • getCentral

      public double getCentral()

      Returns a lazily initialized value of the central attribute. Initialized once and only once and stored for subsequent access with proper synchronization. In case of any exception or error thrown by the lazy value initializer, the result will not be memoised (i.e. remembered) and on next call computation will be attempted again.

      Specified by:
      getCentral in interface Abstraction.Distribution
      Specified by:
      getCentral in interface EmpiricalDistribution
      Returns:
      A lazily initialized value of the central attribute
    • copyOf

      public static ImmutableEmpiricalDistribution copyOf(EmpiricalDistribution instance)
      Creates an immutable copy of a EmpiricalDistribution value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable EmpiricalDistribution instance
    • toBuilder

      Creates a builder for ImmutableEmpiricalDistribution.prefilled with attibute values of this instance to easily create modified copies.
      Returns:
      A new ImmutableEmpiricalDistribution builder with attributes of this instance
    • builder

      public static ImmutableEmpiricalDistribution.Builder builder()
      Creates a builder for ImmutableEmpiricalDistribution.
       ImmutableEmpiricalDistribution.builder()
          .setMinimum(double) // required minimum
          .setMaximum(double) // required maximum
          .setX(double) // required x
          .setCumulativeProbability(double) // required cumulativeProbability
          .build();
       
      Returns:
      A new ImmutableEmpiricalDistribution builder