Class DoubleStatistics.Builder

java.lang.Object
org.apache.commons.statistics.descriptive.DoubleStatistics.Builder
Enclosing class:
DoubleStatistics

public static final class DoubleStatistics.Builder extends Object
A builder for DoubleStatistics.
Since:
1.1
  • Field Details

  • Constructor Details

    • Builder

      Builder()
      Create an instance.
  • Method Details

    • add

      Add the statistic to the statistics to compute.
      Parameters:
      statistic - Statistic to compute.
      Returns:
      this instance
    • createMoment

      private void createMoment(int order)
      Creates the moment constructor for the specified order, e.g. order=2 is sum of squared deviations.
      Parameters:
      order - Order.
    • setConfiguration

      Sets the statistics configuration options for computation of statistics.
      Parameters:
      v - Value.
      Returns:
      the builder
      Throws:
      NullPointerException - if the value is null
    • build

      public DoubleStatistics build()
      Builds a DoubleStatistics instance.
      Returns:
      DoubleStatistics instance.
    • build

      public DoubleStatistics build(double... values)
      Builds a DoubleStatistics instance using the input values.

      Note: DoubleStatistics computed using accept may be different from this instance.

      Parameters:
      values - Values.
      Returns:
      DoubleStatistics instance.
    • build

      public DoubleStatistics build(double[] values, int from, int to)
      Builds a DoubleStatistics instance using the specified range of values.

      Note: DoubleStatistics computed using accept may be different from this instance.

      Parameters:
      values - Values.
      from - Inclusive start of the range.
      to - Exclusive end of the range.
      Returns:
      DoubleStatistics instance.
      Throws:
      IndexOutOfBoundsException - if the sub-range is out of bounds
      Since:
      1.2
    • create

      private DoubleStatistics create(double[] values, int from, int to)
      Builds a DoubleStatistics instance using the input values.

      Note: DoubleStatistics computed using accept may be different from this instance.

      Warning: No range checks are performed.

      Parameters:
      values - Values.
      from - Inclusive start of the range.
      to - Exclusive end of the range.
      Returns:
      DoubleStatistics instance.
    • create

      private static <S,T> T create(Function<S,T> constructor, S values)
      Creates the object from the values.
      Type Parameters:
      S - value type
      T - object type
      Parameters:
      constructor - Constructor.
      values - Values
      Returns:
      the instance
    • create

      private static <S,T> T create(RangeFunction<S,T> constructor, S values, int from, int to)
      Creates the object from the values.
      Type Parameters:
      S - value type
      T - object type
      Parameters:
      constructor - Constructor.
      values - Values
      from - Inclusive start of the range.
      to - Exclusive end of the range.
      Returns:
      the instance
    • create

      private static <R,S,T> T create(RangeBiFunction<R,S,T> constructor, R r, S s, int from, int to)
      Creates the object from the values r and s.
      Type Parameters:
      R - value type
      S - value type
      T - object type
      Parameters:
      constructor - Constructor.
      r - Value.
      s - Value.
      from - Inclusive start of the range.
      to - Exclusive end of the range.
      Returns:
      the instance