Package dev.nm.stat.descriptive.rank
Class Rank
- java.lang.Object
-
- dev.nm.stat.descriptive.rank.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 isrank
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Rank.TiesMethod
The method for assigning ranks when some values are equal (called 'ties').
-
Constructor Summary
Constructors Constructor Description Rank(double[] values)
Compute the sample ranks of the values.Rank(double[] values, double threshold)
Compute the sample ranks of the values.Rank(double[] values, double threshold, Rank.TiesMethod tiesMethod)
Compute the sample ranks of the values.Rank(double[] values, Rank.TiesMethod tiesMethod)
Compute the sample ranks of the values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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) \]
-
-
-
Constructor Detail
-
Rank
public Rank(double[] values)
Compute the sample ranks of the values. Use Rank.TiesMethod.AS_26 as the default method for breaking ties.- Parameters:
values
- the values
-
Rank
public Rank(double[] values, double threshold)
Compute the sample ranks of the values. Use Rank.TiesMethod.AS_26 as the default method for breaking ties.- Parameters:
values
- the valuesthreshold
- 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, Rank.TiesMethod tiesMethod)
Compute the sample ranks of the values.- Parameters:
values
- the valuestiesMethod
- the method that determines ranks for ties
-
Rank
public Rank(double[] values, double threshold, Rank.TiesMethod tiesMethod)
Compute the sample ranks of the values.- Parameters:
values
- the valuesthreshold
- 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.tiesMethod
- the method that determines ranks for ties
-
-
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
-
-