Class Statistics


  • public class Statistics
    extends Object
    Provides implementations of common statistical functions. These functions are for calculating aggregations within the fields of a record. To calculate aggregations over an entire data set, use Group instead.
    See Also:
    ScalarValuedFunction, DeriveFields
    • Constructor Detail

      • Statistics

        public Statistics()
    • Method Detail

      • avg

        public static ScalarValuedFunction avg​(String... fields)
        Builds an expression computing the average of the values of the specified fields.
        Parameters:
        fields - the fields to include in the average
        Returns:
        a function evaluating the expression
      • avg

        public static ScalarValuedFunction avg​(List<ScalarValuedFunction> exprs)
        Builds an expression computing the average of the specified expressions.
        Parameters:
        exprs - the expressions to include in the average
        Returns:
        a function evaluating the expression
      • wavg

        public static ScalarValuedFunction wavg​(String[] fields,
                                                double[] weights)
        Builds an expression computing the weighted average of the values of the specified fields.
        Parameters:
        fields - the fields to include in the average
        weights - the weights to apply to each field
        Returns:
        a function evaluating the expression
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if the number of weights does not match the number of fields
      • wavg

        public static ScalarValuedFunction wavg​(List<ScalarValuedFunction> exprs,
                                                double[] weights)
        Builds an expression computing the weighted average of the values of the specified expressions.
        Parameters:
        exprs - the expressions to include in the average
        weights - the weights to apply to each expression
        Returns:
        a function evaluating the expression
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if the number of weights does not match the number of expressions or if no expressions are supplied