Class DoubleStatistics.Builder

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private StatisticsConfiguration config
      Configuration options for computation of statistics.
      private java.util.function.Function<double[],​Max> max
      The Max constructor.
      private java.util.function.Function<double[],​Min> min
      The Min constructor.
      private java.util.function.BiFunction<org.apache.commons.numbers.core.Sum,​double[],​FirstMoment> moment
      The moment constructor.
      private int momentOrder
      The order of the moment.
      private static double[] NO_VALUES
      An empty double array.
      private java.util.function.Function<double[],​Product> product
      The Product constructor.
      private java.util.function.Function<org.apache.commons.numbers.core.Sum,​Sum> sum
      The Sum constructor.
      private java.util.function.Function<double[],​SumOfLogs> sumOfLogs
      The SumOfLogs constructor.
      private java.util.function.Function<double[],​SumOfSquares> sumOfSquares
      The SumOfSquares constructor.
    • Constructor Summary

      Constructors 
      Constructor Description
      Builder()
      Create an instance.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) DoubleStatistics.Builder add​(Statistic statistic)
      Add the statistic to the statistics to compute.
      DoubleStatistics build()
      Builds a DoubleStatistics instance.
      DoubleStatistics build​(double... values)
      Builds a DoubleStatistics instance using the input values.
      private static <R,​S,​T>
      T
      create​(java.util.function.BiFunction<R,​S,​T> constructor, R r, S s)
      Creates the object from the values r and s.
      private static <S,​T>
      T
      create​(java.util.function.Function<S,​T> constructor, S values)
      Creates the object from the values.
      private void createMoment​(int order)
      Creates the moment constructor for the specified order, e.g.
      DoubleStatistics.Builder setConfiguration​(StatisticsConfiguration v)
      Sets the statistics configuration options for computation of statistics.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NO_VALUES

        private static final double[] NO_VALUES
        An empty double array.
      • min

        private java.util.function.Function<double[],​Min> min
        The Min constructor.
      • max

        private java.util.function.Function<double[],​Max> max
        The Max constructor.
      • moment

        private java.util.function.BiFunction<org.apache.commons.numbers.core.Sum,​double[],​FirstMoment> moment
        The moment constructor. May return any instance of FirstMoment.
      • sum

        private java.util.function.Function<org.apache.commons.numbers.core.Sum,​Sum> sum
        The Sum constructor.
      • product

        private java.util.function.Function<double[],​Product> product
        The Product constructor.
      • sumOfSquares

        private java.util.function.Function<double[],​SumOfSquares> sumOfSquares
        The SumOfSquares constructor.
      • sumOfLogs

        private java.util.function.Function<double[],​SumOfLogs> sumOfLogs
        The SumOfLogs constructor.
      • momentOrder

        private int momentOrder
        The order of the moment. It corresponds to the power computed by the FirstMoment instance constructed by moment. This should only be increased from the default of zero (corresponding to no moment computation).
    • Constructor Detail

      • Builder

        Builder()
        Create an instance.
    • Method Detail

      • add

        DoubleStatistics.Builder add​(Statistic statistic)
        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

        public DoubleStatistics.Builder setConfiguration​(StatisticsConfiguration v)
        Sets the statistics configuration options for computation of statistics.
        Parameters:
        v - Value.
        Returns:
        the builder
        Throws:
        java.lang.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.
      • create

        private static <S,​T> T create​(java.util.function.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 <R,​S,​T> T create​(java.util.function.BiFunction<R,​S,​T> constructor,
                                                    R r,
                                                    S s)
        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.
        Returns:
        the instance