Class ImmutableResampledDistribution

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

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

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

See Also:
  • Method Details

    • getFirst

      public Abstraction.Distribution getFirst()
      Specified by:
      getFirst in interface ResampledDistribution
      Returns:
      The value of the first attribute
    • getSecond

      public Abstraction.Distribution getSecond()
      Specified by:
      getSecond in interface ResampledDistribution
      Returns:
      The value of the second attribute
    • getCombiner

      Specified by:
      getCombiner in interface ResampledDistribution
      Returns:
      The value of the combiner attribute
    • getSamples

      public double[] getSamples()
      Specified by:
      getSamples in interface ResampledDistribution
      Returns:
      The computed-at-construction value of the samples attribute
    • getCentral

      public double getCentral()
      Specified by:
      getCentral in interface Abstraction.Distribution
      Specified by:
      getCentral in interface ResampledDistribution
      Returns:
      The computed-at-construction value of the central attribute
    • getMedian

      public double getMedian()
      Specified by:
      getMedian in interface Abstraction.Distribution
      Specified by:
      getMedian in interface ResampledDistribution
      Returns:
      The computed-at-construction value of the median attribute
    • withFirst

      Copy the current immutable object by setting a value for the first attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for first
      Returns:
      A modified copy of the this object
    • withSecond

      Copy the current immutable object by setting a value for the second attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for second
      Returns:
      A modified copy of the this object
    • withCombiner

      Copy the current immutable object by setting a value for the combiner attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for combiner
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(@Nullable Object another)
      This instance is equal to all instances of ImmutableResampledDistribution 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: first, second, combiner, samples, central, median.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

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

      public EmpiricalDistribution getInterpolation()

      Returns a lazily initialized value of the interpolation 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:
      getInterpolation in interface ResampledDistribution
      Returns:
      A lazily initialized value of the interpolation attribute
    • copyOf

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

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

      public static ImmutableResampledDistribution.Builder builder()
      Creates a builder for ImmutableResampledDistribution.
       ImmutableResampledDistribution.builder()
          .setFirst(io.github.ai4ci.abm.mechanics.Abstraction.Distribution) // required first
          .setSecond(io.github.ai4ci.abm.mechanics.Abstraction.Distribution) // required second
          .setCombiner(io.github.ai4ci.abm.mechanics.ModelOperation.BiFunction<Double, Double, Double>) // required combiner
          .build();
       
      Returns:
      A new ImmutableResampledDistribution builder