Class ImmutableHistogramDistribution

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

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

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

See Also:
  • Method Details

    • getSamples

      public double[] getSamples()
      Specified by:
      getSamples in interface HistogramDistribution
      Returns:
      A cloned samples array
    • getX

      public double[] getX()
      Specified by:
      getX in interface HistogramDistribution
      Returns:
      The computed-at-construction value of the x attribute
    • getMin

      public double getMin()
      Specified by:
      getMin in interface HistogramDistribution
      Returns:
      The computed-at-construction value of the min attribute
    • getMax

      public double getMax()
      Specified by:
      getMax in interface HistogramDistribution
      Returns:
      The computed-at-construction value of the max attribute
    • withSamples

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

      public boolean equals(@Nullable Object another)
      This instance is equal to all instances of ImmutableHistogramDistribution 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: samples, x, min, max.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value HistogramDistribution 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 HistogramDistribution
      Returns:
      A lazily initialized value of the central attribute
    • copyOf

      public static ImmutableHistogramDistribution copyOf(HistogramDistribution instance)
      Creates an immutable copy of a HistogramDistribution 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 HistogramDistribution instance
    • toBuilder

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

      public static ImmutableHistogramDistribution.Builder builder()
      Creates a builder for ImmutableHistogramDistribution.
       ImmutableHistogramDistribution.builder()
          .setSamples(double) // required samples
          .build();
       
      Returns:
      A new ImmutableHistogramDistribution builder