uk.ac.starlink.ttools.func
Class Arrays

java.lang.Object
  extended by uk.ac.starlink.ttools.func.Arrays

public class Arrays
extends Object

Functions which perform aggregating operations on array-valued cells. The functions in this class such as mean, sum, maximum etc can only be used on values which are already arrays. In most cases that means on values in table columns which are declared as array-valued. FITS and VOTable tables can have columns which contain array values, but other formats such as CSV cannot.

There is also a set of functions named array with various numbers of arguments, which let you assemble an array value from a list of scalar numbers. This can be used for instance to get the mean of a set of three magnitudes by using an expression like "mean(array(jmag, hmag, kmag))".

Since:
14 Jul 2008
Author:
Mark Taylor

Method Summary
static double[] array(double x1)
          Returns a numeric array built from a given element.
static double[] array(double x1, double x2)
          Returns a numeric array built from given elements.
static double[] array(double x1, double x2, double x3)
          Returns a numeric array built from given elements.
static double[] array(double x1, double x2, double x3, double x4)
          Returns a numeric array built from given elements.
static double[] array(double x1, double x2, double x3, double x4, double x5)
          Returns a numeric array built from given elements.
static double[] array(double x1, double x2, double x3, double x4, double x5, double x6)
          Returns a numeric array built from given elements.
static double[] array(double x1, double x2, double x3, double x4, double x5, double x6, double x7)
          Returns a numeric array built from given elements.
static double[] array(double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8)
          Returns a numeric array built from given elements.
static int count(Object array)
          Returns the number of non-blank elements in the array.
static String join(Object array, String joiner)
          Returns a string composed of concatenating all the elements of an array, separated by a joiner string.
static double maximum(Object array)
          Returns the largest of the non-blank elements in the array.
static double mean(Object array)
          Returns the mean of all the non-blank elements in the array.
static double median(Object array)
          Returns the median of the non-blank elements in the array.
static double minimum(Object array)
          Returns the smallest of the non-blank elements in the array.
static double quantile(Object array, double quant)
          Returns a quantile value of the non-blank elements in the array.
static int size(Object array)
          Returns the number of elements in the array.
static double stdev(Object array)
          Returns the population standard deviation of all the non-blank elements in the array.
static double sum(Object array)
          Returns the sum of all the non-blank elements in the array.
static double variance(Object array)
          Returns the population variance of all the non-blank elements in the array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sum

public static double sum(Object array)
Returns the sum of all the non-blank elements in the array. If array is not a numeric array, null is returned.

Parameters:
array - array of numbers
Returns:
sum of all the numeric values in array

mean

public static double mean(Object array)
Returns the mean of all the non-blank elements in the array. If array is not a numeric array, null is returned.

Parameters:
array - array of numbers
Returns:
mean of all the numeric values in array

variance

public static double variance(Object array)
Returns the population variance of all the non-blank elements in the array. If array is not a numeric array, null is returned.

Parameters:
array - array of numbers
Returns:
variance of the numeric values in array

stdev

public static double stdev(Object array)
Returns the population standard deviation of all the non-blank elements in the array. If array is not a numeric array, null is returned.

Parameters:
array - array of numbers
Returns:
standard deviation of the numeric values in array

minimum

public static double minimum(Object array)
Returns the smallest of the non-blank elements in the array. If array is not a numeric array, null is returned.

Parameters:
array - array of numbers
Returns:
minimum of the numeric values in array

maximum

public static double maximum(Object array)
Returns the largest of the non-blank elements in the array. If array is not a numeric array, null is returned.

Parameters:
array - array of numbers
Returns:
maximum of the numeric values in array

median

public static double median(Object array)
Returns the median of the non-blank elements in the array. If array is not a numeric array, null is returned.

Parameters:
array - array of numbers
Returns:
median of the numeric values in array

quantile

public static double quantile(Object array,
                              double quant)
Returns a quantile value of the non-blank elements in the array. Which quantile is determined by the quant value; values of 0, 0.5 and 1 give the minimum, median and maximum respectively. A value of 0.99 would give the 99th percentile.

Parameters:
array - array of numbers
quant - number in the range 0-1 deterining which quantile to calculate
Returns:
quantile corresponding to quant

size

public static int size(Object array)
Returns the number of elements in the array. If array is not an array, zero is returned.

Parameters:
array - array
Returns:
size of array

count

public static int count(Object array)
Returns the number of non-blank elements in the array. If array is not an array, zero is returned.

Parameters:
array - array (may or may not be numeric)
Returns:
number of non-blank elements in array

join

public static String join(Object array,
                          String joiner)
Returns a string composed of concatenating all the elements of an array, separated by a joiner string. If array is not an array, null is returned.

Parameters:
array - array of numbers or strings
joiner - text string to interpose between adjacent elements
Returns:
string composed of array elements separated by joiner strings

array

public static double[] array(double x1)
Returns a numeric array built from a given element.

Parameters:
x1 - array element 1
Returns:
1-element array

array

public static double[] array(double x1,
                             double x2)
Returns a numeric array built from given elements.

Parameters:
x1 - array element 1
x2 - array element 2
Returns:
2-element array

array

public static double[] array(double x1,
                             double x2,
                             double x3)
Returns a numeric array built from given elements.

Parameters:
x1 - array element 1
x2 - array element 2
x3 - array element 3
Returns:
3-element array

array

public static double[] array(double x1,
                             double x2,
                             double x3,
                             double x4)
Returns a numeric array built from given elements.

Parameters:
x1 - array element 1
x2 - array element 2
x3 - array element 3
x4 - array element 4
Returns:
4-element array

array

public static double[] array(double x1,
                             double x2,
                             double x3,
                             double x4,
                             double x5)
Returns a numeric array built from given elements.

Parameters:
x1 - array element 1
x2 - array element 2
x3 - array element 3
x4 - array element 4
x5 - array element 5
Returns:
5-element array

array

public static double[] array(double x1,
                             double x2,
                             double x3,
                             double x4,
                             double x5,
                             double x6)
Returns a numeric array built from given elements.

Parameters:
x1 - array element 1
x2 - array element 2
x3 - array element 3
x4 - array element 4
x5 - array element 5
x6 - array element 6
Returns:
6-element array

array

public static double[] array(double x1,
                             double x2,
                             double x3,
                             double x4,
                             double x5,
                             double x6,
                             double x7)
Returns a numeric array built from given elements.

Parameters:
x1 - array element 1
x2 - array element 2
x3 - array element 3
x4 - array element 4
x5 - array element 5
x6 - array element 6
x7 - array element 7
Returns:
7-element array

array

public static double[] array(double x1,
                             double x2,
                             double x3,
                             double x4,
                             double x5,
                             double x6,
                             double x7,
                             double x8)
Returns a numeric array built from given elements.

Parameters:
x1 - array element 1
x2 - array element 2
x3 - array element 3
x4 - array element 4
x5 - array element 5
x6 - array element 6
x7 - array element 7
x8 - array element 8
Returns:
8-element array


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.