# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.descriptive.rank

## Class Rank

• public class Rank
extends Object
Rank is a relationship between a set of items such that, for any two items, the first is either "ranked higher than", "ranked lower than" or "ranked equal to" the second. This is known as a weak order or total preorder of objects. It is not necessarily a total order of objects because two different objects can have the same ranking. The rankings themselves are totally ordered. In statistics, "ranking" refers to the data transformation in which numerical or ordinal values are replaced by their rank when the data are sorted. It is important to note that ranks can sometimes have non-integer values for tied data values. Thus, in one way of treating tied data values, when there is an even number of copies of the same data value, the statistical rank (being the median rank of the tied data) can end in ½ or another fraction.

The R equivalent function is rank.

• Wikipedia: Ranking
• Wikipedia: Ranking in statistics
• "Algorithm AS 26: Ranking an Array of Numbers. P. R. Freeman. Journal of the Royal Statistical Society. Series C (Applied Statistics) Vol. 19, No. 1 (1970), p. 111-113."
• "Remark AS R7: A Remark on Algorithm AS 26: Ranking an Array of Numbers. P. R. Freeman. Journal of the Royal Statistical Society. Series C (Applied Statistics), Vol. 22, No. 1 (1973), p. 133."
• ### Constructor Summary

Constructors
Constructor and Description
Rank(double[] values)
Compute the sample ranks of the values.
Rank(double[] values, double threshold)
Compute the sample ranks of the values.
• ### Method Summary

All Methods
Modifier and Type Method and Description
double rank(int i)
Get the rank of the i-th element.
double[] ranks()
Get the ranks of the values.
double s()
$s = \sum(t_i^2 - t_i)$
double t()
/[ t = \sum(t_i^3 - t_i) \]
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### Rank

public Rank(double[] values,
double threshold)
Compute the sample ranks of the values.
Parameters:
values - the values
threshold - the tie threshold. If successive elements of the sorted array differ by less than the threshold, they are treated as equal. We count the number of ties in each group.
• #### Rank

public Rank(double[] values)
Compute the sample ranks of the values.
Parameters:
values - the values
• ### Method Detail

• #### rank

public double rank(int i)
Get the rank of the i-th element.
Parameters:
i - the index to a value
Returns:
the rank of the i-th element
• #### ranks

public double[] ranks()
Get the ranks of the values.
Returns:
the ranks
• #### t

public double t()
/[ t = \sum(t_i^3 - t_i) \]
Returns:
t
• #### s

public double s()
$s = \sum(t_i^2 - t_i)$
Returns:
s