Package uk.ac.starlink.ttools.func
Class Lists
- java.lang.Object
-
- uk.ac.starlink.ttools.func.Lists
-
public class Lists extends java.lang.ObjectFunctions which operate on lists of values.Some of these resemble similar functions in the
Arraysclass, 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 alreadydouble[]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
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcountTrue(boolean... values)Returns the number of true values in a list of boolean arguments.static doublemax(double... values)Returns the maximum of all the non-blank supplied arguments.static doublemean(double... values)Returns the mean of all the non-blank supplied arguments.static doublemedian(double... values)Returns the median of all the non-blank supplied arguments.static doublemin(double... values)Returns the minimum of all the non-blank supplied arguments.static doublestdev(double... values)Returns the population standard deviation of the non-blank supplied arguments.static doublesum(double... values)Returns the sum of all the non-blank supplied arguments.static doublevariance(double... values)Returns the population variance of the non-blank supplied arguments.
-
-
-
Method Detail
-
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
valuesthat are true - Examples:
countTrue(false, false, true, false, true) = 2
-
-