Class Lists

java.lang.Object
uk.ac.starlink.ttools.func.Lists

public class Lists extends Object
Functions which operate on lists of values.

Some of these resemble similar functions in the Arrays class, and in some cases are interchangeable, but these are easier to use on non-array values because you don't have to explicitly wrap up lists of arguments as an array. However, for implementation reasons, most of the functions defined here can be used on values which are already double[] arrays (for instance array-valued columns) rather than as comma-separated lists of floating point values.

Since:
6 Jan 2015
Author:
Mark Taylor
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    countTrue(boolean... values)
    Returns the number of true values in a list of boolean arguments.
    static double
    max(double... values)
    Returns the maximum of all the non-blank supplied arguments.
    static double
    mean(double... values)
    Returns the mean of all the non-blank supplied arguments.
    static double
    median(double... values)
    Returns the median of all the non-blank supplied arguments.
    static double
    min(double... values)
    Returns the minimum of all the non-blank supplied arguments.
    static double
    stdev(double... values)
    Returns the population standard deviation of the non-blank supplied arguments.
    static double
    sum(double... values)
    Returns the sum of all the non-blank supplied arguments.
    static double
    variance(double... values)
    Returns the population variance of the non-blank supplied arguments.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • sum

      public static double sum(double... values)
      Returns the sum of all the non-blank supplied arguments.
      Parameters:
      values - one or more numeric values
      Returns:
      sum of values
      Examples:
      sum(1, 3, 99) = 103, sum(1, 3, NaN) = 4
    • mean

      public static double mean(double... values)
      Returns the mean of all the non-blank supplied arguments.
      Parameters:
      values - one or more numeric values
      Returns:
      mean of values
      Examples:
      mean(2, 4, 6, 8) = 5, mean(100.5, 99.5, NaN) = 100
    • variance

      public static double variance(double... values)
      Returns the population variance of the non-blank supplied arguments.
      Parameters:
      values - one or more numeric values
      Returns:
      population variance of values
      Examples:
      variance(0, 3, 4, 3, 0) = 2.8, variance(0, 3, NaN, 3, NaN) = 2
    • stdev

      public static double stdev(double... values)
      Returns the population standard deviation of the non-blank supplied arguments.
      Parameters:
      values - one or more numeric values
      Returns:
      population standard deviation of values
      Examples:
      stdev(-3, -2, 0, 0, 1, 2, 3, 4, 5, 6) = 2.8
    • min

      public static double min(double... values)
      Returns the minimum of all the non-blank supplied arguments.
      Parameters:
      values - one or more numeric values
      Returns:
      minimum of values
      Examples:
      min(20, 25, -50, NaN, 101) = -50
    • max

      public static double max(double... values)
      Returns the maximum of all the non-blank supplied arguments.
      Parameters:
      values - one or more numeric values
      Returns:
      maximum of values
      Examples:
      max(20, 25, -50, NaN, 101) = 101
    • median

      public static double median(double... values)
      Returns the median of all the non-blank supplied arguments.
      Parameters:
      values - one or more numeric values
      Returns:
      median of values
      Examples:
      median(-100000, 5, 6, 7, 8) = 6
    • countTrue

      public static int countTrue(boolean... values)
      Returns the number of true values in a list of boolean arguments. Note if any of the values are blank, the result may be blank as well.
      Parameters:
      values - one or more true/false values
      Returns:
      number of elements of values that are true
      Examples:
      countTrue(false, false, true, false, true) = 2