Class Rank
- java.lang.Object
-
- ubic.basecode.math.Rank
-
public class Rank extends Object
Calculate rank statistics for arrays.- Author:
- Paul Pavlidis
-
-
Constructor Summary
Constructors Constructor Description Rank()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static cern.colt.list.IntArrayList
order(cern.colt.list.DoubleArrayList array)
Return a permutation which puts the array in sorted order.static long
rankSum(List<Double> ranks)
static cern.colt.list.DoubleArrayList
rankTransform(cern.colt.list.DoubleArrayList array)
Rank transform an array.static cern.colt.list.DoubleArrayList
rankTransform(cern.colt.list.DoubleArrayList array, boolean descending)
Rank transform an array.static <K> Map<K,Double>
rankTransform(Map<K,? extends Comparable<?>> m)
Rank transform a map, where the values are Comparable values we wish to rank.static <K> Map<K,Double>
rankTransform(Map<K,? extends Comparable<?>> m, boolean desc)
Ties are broken as for the other methods.
-
-
-
Method Detail
-
order
public static cern.colt.list.IntArrayList order(cern.colt.list.DoubleArrayList array)
Return a permutation which puts the array in sorted order. In other words, the values returned indicate the positions of the sorted values in the original array (the lowest value has the lowest rank, but it could be located anywhere in the array). Indexes start from 0. Tied values are put in an arbitrary ordering.- Parameters:
array
-- Returns:
-
rankTransform
public static cern.colt.list.DoubleArrayList rankTransform(cern.colt.list.DoubleArrayList array)
Rank transform an array. The ranks are constructed based on the sort order of the elements. That is, low values get low numbered ranks starting from 1.Ties are resolved by assigning the average rank for tied values. For example, instead of arbitrarily assigning ties ranks 3,4,5, all three values would get a rank of 4 and no value would get a rank of 3 or 5.
Missing values are sorted in their natural order, which means they end up all at one end (at the high ('bad') end)
- Parameters:
array
- DoubleArrayListarray
- , or null if the ranks could not be computed.- Returns:
- cern.colt.list.DoubleArrayList
-
rankTransform
public static cern.colt.list.DoubleArrayList rankTransform(cern.colt.list.DoubleArrayList array, boolean descending)
Rank transform an array. The ranks are constructed based on the sort order of the elements. That is, low values get low numbered ranks starting from 1, unless you set descending = true.Ties are resolved by assigning the average rank for tied values. For example, instead of arbitrarily assigning ties ranks 3,4,5, all three values would get a rank of 4 and no value would get a rank of 3 or 5.
Missing values are sorted in their natural order, which means they end up all at one end (at the high ('bad') end)
- Parameters:
array
- DoubleArrayListdescending
- - reverse the usual ordering so larger values are the the front.- Returns:
- cern.colt.list.DoubleArrayList, or null if the input is empty or null.
-
rankTransform
public static <K> Map<K,Double> rankTransform(Map<K,? extends Comparable<?>> m)
Rank transform a map, where the values are Comparable values we wish to rank. Ties are broken as for the other methods. Ranks are zero-basedMissing values are sorted in their natural order, which means they end up all at one end (at the high ('bad') end)
- Parameters:
m
- java.util.Map with keys Objects, values Doubles.- Returns:
- A java.util.Map keys=old keys, values=java.lang.Double rank of the key. Non-integer values mean tie splits.
-
rankTransform
public static <K> Map<K,Double> rankTransform(Map<K,? extends Comparable<?>> m, boolean desc)
Ties are broken as for the other methods. CAUTION - ranks start at 0.Missing values are sorted in their natural order, which means they end up all at one end (at the high ('bad') end)
- Type Parameters:
K
-- Parameters:
m
-desc
- if true, the lowest (first) rank will be for the highest value.- Returns:
- A java.util.Map keys=old keys, values=java.lang.Double rank of the key. Non-integer values mean tie splits.
-
-