Record Class DoubleSummary

java.lang.Object
java.lang.Record
io.jenetics.stat.DoubleSummary
Record Components:
count - the count of values recorded
min - the minimum value recorded, or Double.POSITIVE_INFINITY if no values have been recorded
max - the maximum value recorded, or Double.NEGATIVE_INFINITY if no values have been recorded
sum - the sum of values recorded, or zero if no values have been recorded
mean - the arithmetic mean of values recorded, or zero if no values have been recorded
All Implemented Interfaces:
Serializable

public record DoubleSummary(long count, double min, double max, double sum, double mean) extends Record implements Serializable
Value objects which contains statistical summary information.
Since:
3.0
Version:
7.0
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    DoubleSummary(long count, double min, double max, double sum, double mean)
    Creates an instance of a DoubleSummary record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the value of the count record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    double
    max()
    Returns the value of the max record component.
    static double
    max(double[] values)
    Return the maximum value of the given double array.
    double
    Returns the value of the mean record component.
    static double
    mean(double[] values)
    Returns a double describing the arithmetic mean of the values, or Double.NaN if the values array is empty.
    double
    min()
    Returns the value of the min record component.
    static double
    min(double[] values)
    Return the minimum value of the given double array.
    Return a new value object of the statistical summary, currently represented by the statistics object.
    double
    sum()
    Returns the value of the sum record component.
    static double
    sum(double[] values)
    Return the sum of the given double array.
    static <T> Collector<T,?,DoubleSummary>
    toDoubleSummary(ToDoubleFunction<? super T> mapper)
    Return a Collector which applies a double-producing mapping function to each input element, and return summary-statistics for the resulting values.
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DoubleSummary

      public DoubleSummary(long count, double min, double max, double sum, double mean)
      Creates an instance of a DoubleSummary record class.
      Parameters:
      count - the value for the count record component
      min - the value for the min record component
      max - the value for the max record component
      sum - the value for the sum record component
      mean - the value for the mean record component
  • Method Details

    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • of

      public static DoubleSummary of(DoubleSummaryStatistics statistics)
      Return a new value object of the statistical summary, currently represented by the statistics object.
      Parameters:
      statistics - the creating (mutable) statistics class
      Returns:
      the statistical moments
    • toDoubleSummary

      public static <T> Collector<T,?,DoubleSummary> toDoubleSummary(ToDoubleFunction<? super T> mapper)
      Return a Collector which applies a double-producing mapping function to each input element, and return summary-statistics for the resulting values.
      final Stream<SomeObject> stream = ...;
      final DoubleSummary summary = stream
          .collect(toDoubleSummary(v -> v.doubleValue()));
      
      Type Parameters:
      T - the type of the input elements
      Parameters:
      mapper - a mapping function to apply to each element
      Returns:
      a Collector implementing the summary-statistics reduction
      Throws:
      NullPointerException - if the given mapper is null
    • min

      public static double min(double[] values)
      Return the minimum value of the given double array.
      Parameters:
      values - the double array.
      Returns:
      the minimum value or Double.NaN if the given array is empty.
      Throws:
      NullPointerException - if the given array is null.
      Since:
      4.0
    • max

      public static double max(double[] values)
      Return the maximum value of the given double array.
      Parameters:
      values - the double array.
      Returns:
      the maximum value or Double.NaN if the given array is empty.
      Throws:
      NullPointerException - if the given array is null.
      Since:
      4.0
    • sum

      public static double sum(double[] values)
      Return the sum of the given double array.
      Parameters:
      values - the values to sum up.
      Returns:
      the sum of the given values.
      Throws:
      NullPointerException - if the given array is null.
      Since:
      4.0
    • mean

      public static double mean(double[] values)
      Returns a double describing the arithmetic mean of the values, or Double.NaN if the values array is empty.
      Parameters:
      values - the values to calculate the mean of
      Returns:
      the arithmetic mean of the given values or Double.NaN if the values array is empty
      Throws:
      NullPointerException - if the given array is null.
      Since:
      4.0
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • count

      public long count()
      Returns the value of the count record component.
      Returns:
      the value of the count record component
    • min

      public double min()
      Returns the value of the min record component.
      Returns:
      the value of the min record component
    • max

      public double max()
      Returns the value of the max record component.
      Returns:
      the value of the max record component
    • sum

      public double sum()
      Returns the value of the sum record component.
      Returns:
      the value of the sum record component
    • mean

      public double mean()
      Returns the value of the mean record component.
      Returns:
      the value of the mean record component