org.statcato.utils
Class OrderingFunctions

java.lang.Object
  extended by org.statcato.utils.OrderingFunctions

public class OrderingFunctions
extends java.lang.Object

Functions for ordering column cells.

Since:
1.0
Version:
%I%, %G%
Author:
Margaret Yau

Constructor Summary
OrderingFunctions()
           
 
Method Summary
static double[] rank(java.util.Vector<DataValue> data)
          Returns the ranks of the given DataValue objects.
static java.util.Vector<java.lang.Integer> rankColumnVector(java.util.Vector<Cell> vec, boolean ascending)
          Given a vector of Cells and the sort order, return a vector of Integers that are the ranks of the Cells.
static double[] rankDoubleVector(java.util.Vector<java.lang.Double> data)
          Returns the ranks of the given DataValue objects.
static java.util.Vector<Cell> sortColumnVector(java.util.Vector<Cell> vec, java.util.Vector<Cell> byVec, boolean ascending)
          Sorts a vector of Cell based on another vector of Cell in the given order.
static java.util.Vector<java.util.Vector<Cell>> sortVectors(java.util.Vector<java.util.Vector<Cell>> vecs, java.util.Vector<java.lang.Boolean> orders)
          Sorts a set of vectors in place, from the last vector in the set to the first.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrderingFunctions

public OrderingFunctions()
Method Detail

rankColumnVector

public static java.util.Vector<java.lang.Integer> rankColumnVector(java.util.Vector<Cell> vec,
                                                                   boolean ascending)
Given a vector of Cells and the sort order, return a vector of Integers that are the ranks of the Cells. For ascending order, the smallest number has rank 0, and cells with higher order have increasing ranks. For descending order, the largest number has rank 0, and cells with lower order have increasing ranks. Empty cells have no rank.

Parameters:
vec - vector of Cell to be ranked
ascending - sort order
Returns:
a vector of ranks

sortColumnVector

public static java.util.Vector<Cell> sortColumnVector(java.util.Vector<Cell> vec,
                                                      java.util.Vector<Cell> byVec,
                                                      boolean ascending)
Sorts a vector of Cell based on another vector of Cell in the given order.

Parameters:
vec - vector to be sorted
byVec - vector to sort by
ascending - sort order
Returns:
a sorted vector of Cell

sortVectors

public static java.util.Vector<java.util.Vector<Cell>> sortVectors(java.util.Vector<java.util.Vector<Cell>> vecs,
                                                                   java.util.Vector<java.lang.Boolean> orders)
Sorts a set of vectors in place, from the last vector in the set to the first.

Parameters:
vecs - vector of vectors of cells
orders - vector of boolean values indicating the sort orders. Must have the same length as vec.
Returns:
vector of vectors of cells that are sorted

rank

public static double[] rank(java.util.Vector<DataValue> data)
Returns the ranks of the given DataValue objects. Ranks are based on absolute values, and signs of data values are attached to their corresponding ranks. Mean ranks are assigned to tied data values.

Parameters:
data - vector of DataValue objects
Returns:
array of ranks corresponding to the given data values (in the same order)

rankDoubleVector

public static double[] rankDoubleVector(java.util.Vector<java.lang.Double> data)
Returns the ranks of the given DataValue objects. Ranks are based on absolute values, and signs of data values are attached to their corresponding ranks. Mean ranks are assigned to tied data values.

Parameters:
data - vector of DataValue objects
Returns:
array of ranks corresponding to the given data values (in the same order)